From: achrist@easystreet.com
Subject: Re: gnat: float problem
Date: Sun, 07 Jul 2002 14:04:49 -0700
Date: 2002-07-07T14:04:49-07:00 [thread overview]
Message-ID: <3D28ACF1.4720A915@easystreet.com> (raw)
In-Reply-To: pan.2002.07.07.14.03.50.890537.1744@gmx.net
Jan Prazak wrote:
>
> I know that floating point numbers are not very exact, but this really
> looks like a bug, because -5.00000E-01 == -0.5.
This is all fairly reasonable, given that 0.1 cannot be exactly
represented as a floating point on a binary machine. I believe that
this will be rounded and may be approximated as slighltly more than 0.1.
In hexadecimal, this is 0.199999999... I think, so there is a good
chance that rounding will go upward (50% of the less significant bits
being ones).
Question: 0.5 and -0.5 are decimal numbers that can be represented
exactly as floating point. Is the compiler required to figure this
out? If it converted 0.5 to binary the dumb way, ie taking 5 times
0.1, it might not get it right. Which compilers always get this kind
of conversion correct?
Al
prev parent reply other threads:[~2002-07-07 21:04 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2002-07-07 15:06 gnat: float problem Jan Prazak
2002-07-07 14:08 ` Frank J. Lhota
2002-07-08 20:20 ` Jan Prazak
2002-07-08 18:10 ` David C. Hoos
2002-07-09 1:05 ` Robert A Duff
2002-07-09 2:14 ` David C. Hoos, Sr.
2002-07-08 18:19 ` Frank J. Lhota
2002-07-08 19:12 ` tmoran
2002-07-08 19:28 ` achrist
2002-07-08 23:00 ` Jan Prazak
2002-07-08 23:00 ` Jan Prazak
2002-07-08 20:34 ` David C. Hoos
2002-07-09 13:36 ` Ted Dennison
2002-07-09 19:03 ` Jeffrey Carter
2002-07-09 20:07 ` Robert Dewar
2002-07-07 21:04 ` achrist [this message]
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox