Free42 with IEEE 754-2008 decimal floating-point -- interested in a sneak preview? - Printable Version +- HP Forums (https://www.hpmuseum.org/forum) +-- Forum: Not HP Calculators (/forum-7.html) +--- Forum: Not quite HP Calculators - but related (/forum-8.html) +--- Thread: Free42 with IEEE 754-2008 decimal floating-point -- interested in a sneak preview? (/thread-756.html) |
RE: Free42 with IEEE 754-2008 decimal floating-point -- interested in a sneak preview? - Paul Dale - 03-17-2014 11:40 AM (03-16-2014 01:45 PM)Werner Wrote: in DEG mode: I'm not surprised here. 180 + 10^-31 is pushing the number of digits in double precision whereas -10^-31 isn't stretching anything. In single precision there doesn't seem to be an issue thankfully. I know the 34S trigonometric functions don't do the usual full reduction to the first octant before evaluating the functions. I brute force things with a longer series -- it is smaller codewise. There is also the conversion to radians involved to disturb the results a bit. In summary: * not unexpected, * doesn't impact single precision, * will take space to fix. Is it worthwhile trying? I'll see if I can come up with something nice and simple. - Pauli RE: Free42 with IEEE 754-2008 decimal floating-point - interested in a sneak preview? - Thomas Okken - 03-17-2014 01:29 PM (03-17-2014 11:08 AM)J-F Garnier Wrote: I noted that there is also a similar issue in the reverse situation: OK, I'll add code to handle powers of 10 in LOG. (I'm amazed that code isn't there already, since testing for exact powers of 10 is so easy in decimal. Continuity issues maybe?) Free42 with IEEE 754-2008 decimal floating-point -- interested in a sneak preview? - Thomas Klemm - 03-17-2014 10:03 PM (03-16-2014 03:06 PM)Thomas Okken Wrote: By the way, where can I find out what formatting is supported on this forum? I thought it was strictly plain text here until I saw your [b] tags. :-)Besides the obvious buttons of the editor there are some hidden features:
Cheers Thomas RE: Free42 with IEEE 754-2008 decimal floating-point - interested in a sneak preview? - Thomas Okken - 03-18-2014 12:55 AM (03-17-2014 01:29 PM)Thomas Okken Wrote:(03-17-2014 11:08 AM)J-F Garnier Wrote: I noted that there is also a similar issue in the reverse situation: In order to make sure LOG doesn't just return exact results for exact powers of 10, but also satisfies 10n ≤ x < 10n+1 → n ≤ LOG(x) < n+1 which is necessary for code like FWIW to work reliably, I'm thinking of this argument reduction code: Code: function log10(x) { RE: Free42 with IEEE 754-2008 decimal floating-point - interested in a sneak preview? - Thomas Okken - 03-18-2014 01:03 AM (03-17-2014 10:03 PM)Thomas Klemm Wrote: Besides the obvious buttons of the editor there are some hidden features: [...] Thanks! :-) BTW, the "obvious buttons" weren't obvious to me because I was using Firefox with NoScript at home, and NoScript nixes those buttons, unless you tell it not to. My mistake! - Thomas RE:Free42 with IEEE 754-2008 decimal floating-point -- interested in a sneak preview? - Werner - 03-18-2014 07:16 AM (03-17-2014 01:29 PM)Thomas Okken Wrote: In order to make sure LOG doesn't just return exact results for exact powers of 10, but also satisfies This is not possible. On a real 42S, LOG(9.99999999999) = 1, exactly. Meaning it is the closest number to the exact result. The same holds for any precision. On Free42 Decimal-34, LOG(1e34-1) is 34 and LOG(1e33-1) is 33, exactly, and that's what the result should be. Extracting the exponent should rather be done dividing by the mantissa, that can be determined as follows (thanks to Dieter): Code:
Werner RE: Free42 with IEEE 754-2008 decimal floating-point - interested in a sneak preview? - J-F Garnier - 03-18-2014 07:57 AM (03-18-2014 07:16 AM)Werner Wrote:(03-17-2014 01:29 PM)Thomas Okken Wrote: 10n ≤ x < 10n+1 → n ≤ LOG(x) < n+1This is not possible. I tend to agree with Werner, and the condition above is not needed. Strictly speaking, all we need is that 10^x is exact for x an integer, and it will be nice that LOG(x) is an integer for x exactly a power of ten. J-F RE:Free42 with IEEE 754-2008 decimal floating-point -- interested in a sneak preview? - Werner - 03-18-2014 08:08 AM (03-17-2014 11:40 AM)Paul Dale Wrote: I know the 34S trigonometric functions don't do the usual full reduction to the first octant before evaluating the functions. I brute force things with a longer series -- it is smaller codewise. There is also the conversion to radians involved to disturb the results a bit. Strange that singe precision works, if you don't do the range reduction to the first octant. For me personally, these things are much more important than having 34 digits most of the time. Accuracy over precision, anytime. And of course the venerable 42S gets it right. And Free42, latest version. range reduction to 45° Werner RE: Free42 with IEEE 754-2008 decimal floating-point -- interested in a sneak preview? - Paul Dale - 03-18-2014 08:51 AM It isn't that strange that single precision works properly here: internally I always use a higher precision regardless of the single/double precision mode setting. A bit of brute force here saves a lot of code space and thinking time. I agree accuracy over precision too, that has been my goal all along. I'm not sure we can justify the space to do the octant reduction separately in degrees, radians and gradians and I suspect doing this after the conversion to radians has occurred will result in this problem. Fortunately, it is documented that double precision results can be incorrect in the latter digits for some (most?) functions Double precision was a bit of an after thought which allowed keystroke programs to produce reasonably accurate single precision results -- at least that was its intention. - Pauli RE: Free42 with IEEE 754-2008 decimal floating-point -- interested in a sneak preview? - Werner - 03-18-2014 09:22 AM In that case, might I humbly request that you do consider it for the 43S? Werner RE: Free42 with IEEE 754-2008 decimal floating-point -- interested in a sneak preview? - Paul Dale - 03-18-2014 09:49 AM (03-18-2014 09:22 AM)Werner Wrote: In that case, might I humbly request that you do consider it for the 43S? That sounds more than reasonable. We'll have space there. We will have space on the 31S as well so I guess I'll have to implement it. I've had a bit of an idea about how to do this without using lots of space. Not sure if it will work or not yet... - Pauli RE: Free42 with IEEE 754-2008 decimal floating-point - interested in a sneak preview? - Thomas Okken - 03-18-2014 03:23 PM (03-18-2014 07:16 AM)Werner Wrote: On a real 42S, LOG(9.99999999999) = 1, exactly. Meaning it is the closest number to the exact result. The same holds for any precision. On Free42 Decimal-34, LOG(1e34-1) is 34 and LOG(1e33-1) is 33, exactly, and that's what the result should be. Good point. I don't want to return incorrect results just for the convenience of a flawed algorithm! OK, I'll fix LOG like this: use the bid128_ilogb and bid128_scalbn functions to pull out the exponent and normalize the mantissa to the range [1, 10), then use bid128_log10 on the normalized mantissa, and finally add the exponent to the result. That will return exact results for powers of ten, without introducing numerical inconsistencies. RE: Free42 with IEEE 754-2008 decimal floating-point -- interested in a sneak preview? - Paul Dale - 03-25-2014 08:48 AM The 31S will have appropriate range reduction code in degrees mode but not in radians (it doesn't support gradians). The code space for this is likely more than we want to commit to on the 34S but I coded the gradians modulo reduction too for future use. - Pauli (03-16-2014 01:45 PM)Werner Wrote: in DEG mode: |