Post Reply 
HP 49G: Challenge - Truncate a Long Real
07-07-2015, 06:33 AM
Post: #2
RE: HP 49G: Challenge - Truncate a Long Real
Hi Gerald,

you may use strings for truncating a long real, e.g:

5.12345678901
ENTER
->STR

this converts your real into the string "5.12345678901"

now enter:

1
ENTER
5
ENTER
SUB
ENTER

this truncates your string after the 5th charachter: "5.123"

The last step is to convert the string back to a real:

STR->
ENTER

This leaves 5.123 on Level 1 of the stack.
The only problem is that you need to know the number of charachters to the left of the decimal point because the SUB command strictly counts from left to right.

Hope this helps

Best regards

Karl
Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
RE: HP 49G: Challenge - Truncate a Long Real - Karl-Ludwig Butte - 07-07-2015 06:33 AM



User(s) browsing this thread: 2 Guest(s)