Accuracy loss when calculating magnitudes <1 against magnitudes >1

leif not.really at online.de
Sat May 31 14:24:51 UTC 2014


On 31.05.2014 16:11, bodrato at mail.dm.unipi.it wrote:
> Il Sab, 31 Maggio 2014 4:16 am, Jim Bob ha scritto:
>> I think I have found a bug when calculating numbers regardless of
>> operation yet with magnitudes <1 against numbers with magnitudes >1.
>
> The manual [ https://gmplib.org/manual/Floating_002dpoint-Functions.html ]
> reads:
> "[...] decimal fractions like 0.1 cannot be represented exactly. [...]
> This makes [float and mpf_t] highly unsuitable for calculations involving
> money or other values that should be exact decimal fractions. (Suitably
> scaled integers, or perhaps rationals, are better choices.)"
>
> The "rationals" way was discussed recently on our lists:
> https://gmplib.org/list-archives/gmp-discuss/2014-April/005560.html
> (and previous messages.)

See also http://docs.oracle.com/cd/E19957-01/806-3568/ncg_goldberg.html

("What Every Computer Scientist Should Know About Floating-Point 
Arithmetic"; there are various [edited] copies of this spread around the 
web)


-leif

-- 
() The ASCII Ribbon Campaign
/\   Help Cure HTML E-Mail


More information about the gmp-bugs mailing list