How is this not correct?
Root / Programming Questions / [.]
Gaelstrom_ValenceCreated:
? 129.98-129==0.98I don't know if it's just me, but this always comes out as false, along with any combination of subtracting a value by it's Floored value. EDIT: It seems subtraction with decimals in general is a little wonky.
If you try
PRINT (129.98-129)*1000000you will get "979999.99999999" But, strangely, when you switch things around,
(129.98-0.98)==129it returns true. My advice is if precision is important, then keep everything as a floating point number, or everything as an integer. But don't go between the two. The best explanation I can give is, it's returning a float, but you want it to be an int. Even though it's a precision bug, it seems to easy to work around. This sort of thing happens in lots of programming languages It's still really strange that the only way to see the tiny difference is by blowing up the number. This works though
PRINT STR$(129.98-129)=="0.98"returning true
Eyyyyyy