Re: Division in C++

Andre Poenitz <>
10 Aug 2005 11:53:07 -0400

          From comp.compilers

Related articles
[3 earlier articles]
Re: Division in C++ (Michael Tiomkin) (2005-07-12)
Re: Division in C++ (2005-07-12)
Re: Division in C++ (Florian Weimer) (2005-07-12)
Re: Division in C++ (Gabriel Dos Reis) (2005-07-12)
Re: Division in C++ (Marcin 'Qrczak' Kowalczyk) (2005-07-12)
Re: Division in C++ (Onno Garms) (2005-07-17)
Re: Division in C++ (Andre Poenitz) (2005-08-10)
| List of all articles for this month |

From: Andre Poenitz <>
Newsgroups: comp.compilers,
Date: 10 Aug 2005 11:53:07 -0400
Organization: Chemnitz University of Technology
References: 05-07-046
Keywords: arithmetic
Posted-Date: 10 Aug 2005 11:53:07 EDT

Onno Garms <> wrote:
> Regardless of any rounding errors, a/b should always return
> the same value, shouldn't it?

Not necessarily. Especially on Intel it makes a difference whether
everything happens within the FPU (80bit IIRC) or whether some result or
intermediate result is stored outside (64bit).

Never, ever, trust floating point arithmetic.


PS: Check out the -ffloat-store compiler option.
[Floating point arithmetic is perfectly well defined, but the rules are
different from fixed point, and as you note, intermediate precision
matters a lot. -John]

Post a followup to this message

Return to the comp.compilers page.
Search the comp.compilers archives again.