Re: Division in C++

Andre Poenitz <poenitz@htwm.de>
10 Aug 2005 11:53:07 -0400

          From comp.compilers

Related articles
[3 earlier articles]
Re: Division in C++ tmk@netvision.net.il (Michael Tiomkin) (2005-07-12)
Re: Division in C++ henry@spsystems.net (2005-07-12)
Re: Division in C++ fw@deneb.enyo.de (Florian Weimer) (2005-07-12)
Re: Division in C++ gdr@integrable-solutions.net (Gabriel Dos Reis) (2005-07-12)
Re: Division in C++ qrczak@knm.org.pl (Marcin 'Qrczak' Kowalczyk) (2005-07-12)
Re: Division in C++ garms@gmx.de (Onno Garms) (2005-07-17)
Re: Division in C++ poenitz@htwm.de (Andre Poenitz) (2005-08-10)
| List of all articles for this month |

From: Andre Poenitz <poenitz@htwm.de>
Newsgroups: comp.compilers,gnu.g++.help
Followup-To: gnu.g++.help
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 <garms@gmx.de> 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.


Andre'


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.