Zulu-Inuoe/jzon

Shouldn't test precision of short-float on non-integer-divided-by-power-of-2 (maybe intended to test single-float)

Closed this issue · 1 comments

(is (string= "1.2" (jzon:stringify 1.2s0))))

This test fails on LispWorks 32bit, because the accuracy of short-float is not good enough to represent 1.2. Only numbers that are integers divided by powers of 2 can be confidently assumed to be represented accurately with short-float (which is why it works with 1.5s0).

Looking at these tests, it looks to me like they actually meant to test single-float, rather than short-float. single-float is the standard 32-bit float, while short-float is either shorter or the same thing (depends on the implementation).

https://www.lispworks.com/documentation/lw80/CLHS/Body/t_short_.htm#short-float

Assuming it is intended to test single-float, it should use the exponent marker 'f', as in 1.2f0 (instead of 1.2s0). With 1.2f0 it works "by luck" (you still cannot really rely on it for such numbers, but for 1.2 it works). The same apply for all the other tests with the exponent marker 's'.

https://www.lispworks.com/documentation/lw80/CLHS/Body/26_glo_e.htm#exponent_marker

That's right. I'll patch up the tests, thanks!