bug-gmp
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: gmp 4.1 documentation improvement suggestions


From: Kevin Ryde
Subject: Re: gmp 4.1 documentation improvement suggestions
Date: Wed, 04 Dec 2002 08:00:49 +1000
User-agent: Gnus/5.090008 (Oort Gnus v0.08) Emacs/21.1 (i386-debian-linux-gnu)

Serge Winitzki <address@hidden> writes:
>
> I think this deserves some more documentation.  Most people are so used
> to thinking that "0.1" is an "exact number" that they expect that when
> they take "0.1" with say 10 digits and then increase precision to 100
> digits, the number will stay "exactly 0.1000..0".

Hopefully the fact that this is false is among the first things
everyone learns about binary floating point.  :-)

I'll add the following few words to the mpf introduction though, to
emphasise the binary representation.


   The mantissa in stored in binary, as might be imagined from the fact
precisions are expressed in bits.  One consequence of this is that
decimal fractions like 0.1 cannot be represented exactly.  The same is
true of plain IEEE `double' floats.  This makes both highly unsuitable
for calculations involving money or other values that should be exact
decimal fractions.  (Suitably scaled integers, or perhaps rationals,
are better choices.)




reply via email to

[Prev in Thread] Current Thread [Next in Thread]