Rounding with units - Printable Version +- HP Forums (https://www.hpmuseum.org/forum) +-- Forum: HP Calculators (and very old HP Computers) (/forum-3.html) +--- Forum: HP Prime (/forum-5.html) +--- Thread: Rounding with units (/thread-13961.html) |
Rounding with units - gregreenwood - 11-09-2019 02:40 AM Looks like the round function does not handle numbers with units. I guess because the number with units is really a string? When a round function is used on a value that has units and you try to print via the message box, the message box never appears. The only way I could get it to work is first divide out the units, round, and reapply the units. Did I miss something? RE: Rounding with units - Joe Horn - 11-09-2019 06:25 AM Although it fails in Home, it works in CAS, so a workaround in Home and non-CAS programs is to use either of these syntaxes: CAS.round(unit) CAS.round(unit, places) Only positive values for "places" seem to work. The usual option of using a negative value for "places" (to specify significant digits) does not seem to work. Values greater than 14 for "places" sometimes yield bizarre results (gotta be a bug). RE: Rounding with units - pinkman - 11-09-2019 06:33 AM Yes I didn’t notice but you have to suppress the unit before doing other calculations than +-/* Code:
RE: Rounding with units - Tim Wessman - 11-09-2019 12:02 PM Hmm... i thought rounding and truncation supported units now. Or maybe that was DMS. I will check. RE: Rounding with units - cyrille de brébisson - 11-12-2019 06:17 AM Hello, Sorry, nor unit support for Round (and Trunc, they are the same function)... I will look at what it would take to add it... Units are NOT strings... Units are an object (ie, a pointer to our generic object type, it could actually, tehcnically be anything)... and a list of triplets... Each triplet (3 bytes) is a multiplicator or factor (as in k, m, G...) saved as a signed 8 bit number, normally a multiple of 3, an index in our unit list and a signed byte for the power (which is why unit powers are limited to 127)... Cyrille |