NX Floating Point Arithmetic is nice

2

SP4CEBAR 2023-02-18 09:41

PRINT 0.5+0.5 = 1 returns true
PRINT 0.5+0.5 returns 1

In other languages the result may be 0.9999999 instead of 1, what made NX's floating point arithmetic so nice?


Timo 2023-02-18 22:12

It’s the normal “float” type of C.
I think 0.5 can be represented perfectly in binary, as well as 0.25 and 0.125 etc.
There are other numbers with the problem, but I’m not sure which ones.


SP4CEBAR 2023-02-19 08:54

Thanks, that makes sense


SP4CEBAR 2023-02-20 20:09

I found one:
PRINT 0.07+0.93
prints 0.99999


Log in to reply.