On 11/05/18 23:59, Benito van der Zander wrote:

after all these discussions about the frac function, what is the best way to test if there is a fractional part? That is the most common thing I use frac for

I have always used frac(x) = 0

Is that worse or better than int(x) = x  ?

The only proper way is to use something like Math.SameValue(x, int(x)). Never use equality tests with floating point values, unless you are checking for a specific bit pattern (or if you know that the value can always be represented exactly a sum of power-of-two's).


Jonas
_______________________________________________
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Reply via email to