[fpc-pascal] floating point an FPC

ik idokan at gmail.com
Mon Mar 1 22:32:01 CET 2010


http://ik.homelinux.org/


On Mon, Mar 1, 2010 at 23:20, Jerry <lanceboyle at qwest.net> wrote:

> Don't compare floating points. Ever. Now you see why.
>

So if I need for example to compare currency or something that is floating
point, how do I do that ?


>
> Also, don't write loops that calculate a floating point number which is
> then tested for equality to exit the loop. Also, it is a bad idea to test
> for > or < for exiting unless you know in advance an accidental equality
> result will not yield surprising results. In other other words, don't do
> that (test for > or <) either.
>

As I understand, there is an old way to calculate floating point that is
very popular and newer ways for that.
The old way uses binary calculation and the newer I do not understand them
:)



>
> Jerry
>
> On Feb 26, 2010, at 3:37 AM, ik wrote:
>
> Hello,
>
> I've made a small test:
>
> if (0.1+0.2) = 0.3 then
>
> The only compiler/interpator that actually tells that it equal is FPC.
>
> I've tested it using Javascript (in Firefox), Ruby, Python, C (gcc) and
> Perl.
>
> Except FPC, everyone tells that 0.1+0.2 = 0.30000000000000004
>
> Can someone explain how FPC see the result and why others does not see it
> like that ?
>
>
> Thanks,
> Ido
>
> http://ik.homelinux.org/
>  _______________________________________________
> fpc-pascal maillist  -  fpc-pascal at lists.freepascal.org
> http://lists.freepascal.org/mailman/listinfo/fpc-pascal
>
>
>
> _______________________________________________
> fpc-pascal maillist  -  fpc-pascal at lists.freepascal.org
> http://lists.freepascal.org/mailman/listinfo/fpc-pascal
>


Ido
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freepascal.org/pipermail/fpc-pascal/attachments/20100301/318ad7b4/attachment.html>


More information about the fpc-pascal mailing list