
I repeat for everybody !
When I do this :
Code: Select all
Test.f = 1.50
For i = 1 To 5
Test + 0.30
Next i
In reality it is equal to 2.99999... because float doesn't have infinite precision (stored on 32 bits, so data loss, so bad accuracy) : more you do operations, more you will get a bad result (not accurate)

So when I ask the integer part of 2.9999 (for cpu -3.00 for me-)... Round() or even the Int() function returns "2" instead of "3" : this is a good result for cpu...but wrong result for me because the float should be 3.00, so the integer part should be "3"

Derek, Round() can be used to take integer part with the option "0", so this is exactly the same as Int() but it returns a float value (which is what I want). So Int() doesn't fix it

Psychophanta, thank you for your fix, but there is still a bug.
If I have the number 2.99, it will round to "3" instead of "2", so that's still not accurate : you cannot add a constant value to fix this bad accurary, that's totally wrong.

My tricky fix is the best atm :
Round(ValF(StrF(Float.f)), 0)
I think Fred corrected the bad float accurary in StrF() function, so I get an accurate float string...and when I use it in ValF() I get back the accurate float value
