This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
Re: [Fwd: Formatted Read Accuracy]
- From: Eljay Love-Jensen <eljay at adobe dot com>
- To: Emil Block <blime at his dot com>, gcc-help at gcc dot gnu dot org
- Date: Wed, 09 Oct 2002 13:43:03 -0500
- Subject: Re: [Fwd: Formatted Read Accuracy]
Hi Blime,
Floating point numbers -- IEEE 754, 32-bit "float", 64-bit "double", or any
of the other more-or-less standard formats -- cannot perfectly represent
any arbitrary decimal portion of all rational numbers.
For instance, 0.5 can be perfectly represented.
Consider that "0.5" (decimal) is "0.8" (hexadecimal). Exactly.
0.1 cannot be perfectly represented.
Consider that "0.1" (decimal) would be
"0.1999999999999999999999999999999..." (hexadecimal). Since floating point
numbers do not have infinite precision, some rounding occurs.
To alleviate the problem, consider using fixed point numbers, or using BCD
numbers.
Sincerely,
--Eljay