[fpc-pascal] Re: Why this evaluates on "if" wrong ? (GMP)
Inga Petuhhov
inga at tlu.ee
Tue Oct 30 17:31:08 CET 2007
A copy-paste from Python Shell:
>>> a = 1
>>> a
1
>>> a = a + 0.4
>>> a
1.3999999999999999
>>> a = a - 0.4
>>> a
0.99999999999999989
>>> a == 1
False
Best regards
Inga
PS I always talk to my informatics-students: You never-ever do with
real-variables something like this: if real1 = real2 then ...
Real numbers can be equal with some precision.
On Tue, 30 Oct 2007, Andrea Mauri wrote:
> But someone tried to reproduce the example with other programming languages?
>
>
> mm ha scritto:
>> Tom Verhoeff a écrit :
>>>
>>> In fact, the GMP (GNU Multiple Precision Arithmetic Library <gmplib.org>)
>>> offers this and more. Unfortunately, there does not seem to be a complete
>>> FreePascal interface for it. Maybe it is easy to adapt (if necessary?)
>>> the GNU Pascal interface for GMP <http://www.gnu-pascal.de/gpc/GMP.html>.
>>> I would be interested.
>>
>> But there are multi-precision libraries for Free Pascal.
>>
>> The one I am writing:
>> "NX" (big integers, big reals, big complexes, big polynomials
>> over GF(2)) at
>> http://www.ellipsa.net/
>>
>> An other one:
>> "MPINT" (big integers, big rationals) at
>> http://home.netsurf.de/wolfgang.ehrhardt/misc_en.html#mpint
>>
>> And there are others.
>>
>> mm
>> _______________________________________________
>> fpc-pascal maillist - fpc-pascal at lists.freepascal.org
>> http://lists.freepascal.org/mailman/listinfo/fpc-pascal
>>
>
>
More information about the fpc-pascal
mailing list