This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
Re: Variable assignment and truncation of floats on x86
- To: Joe Murray <jmurray at dsrnet dot com>
- Subject: Re: Variable assignment and truncation of floats on x86
- From: Alexandre Oliva <aoliva at redhat dot com>
- Date: 19 Apr 2001 16:02:56 -0300
- Cc: "'gcc-bugs at gcc dot gnu dot org'" <gcc-bugs at gcc dot gnu dot org>
- Organization: GCC Team, Red Hat
- References: <01D3C2F94514D31187EB005004776D202565B8@ENG_TECH_SVR>
On Apr 18, 2001, Joe Murray <jmurray@dsrnet.com> wrote:
> 3 results in: 7.0000000000 (actually probably 6.999999? rounded to
> 7.00000000)
> 4 results in: 6 <------- PROBLEM WITH INPLACE ASSIGNMENT
> 5 results in: 7 (correct answer)
FP is not exact, and is, in a sense, even less exact on x86, in which
the result depends on whether the intermediate result was kept in an
80-bit FP register or was stored in a 64-bit memory location. I
suppose you man want to use roundf() to avoid getting 6.999999
truncated to 6.
--
Alexandre Oliva Enjoy Guarana', see http://www.ic.unicamp.br/~oliva/
Red Hat GCC Developer aoliva@{cygnus.com, redhat.com}
CS PhD student at IC-Unicamp oliva@{lsd.ic.unicamp.br, gnu.org}
Free Software Evangelist *Please* write to mailing lists, not to me