[fpc-pascal] Freepascal Floating Point Issue

Sven Barth pascaldragon at googlemail.com
Tue Aug 22 07:54:31 CEST 2017


Am 22.08.2017 00:02 schrieb "James Richters" <james at productionautomation.net
>:

The others already wrote about floating point precision, so I won't repeat
that.

> The reason I noticed this is because I have some conditional statements
like
> If Draw_GX_Min<>99.999 then
>     Something....

*DON'T* compare floating point numbers like that. Instead use SameValue()
from the Math unit which has an additional epsilon value (with a default
value) that defines a lower and upper bound from your desired value to
compare to.

Regards,
Sven
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freepascal.org/pipermail/fpc-pascal/attachments/20170822/e30d1b95/attachment.html>


More information about the fpc-pascal mailing list