This is the mail archive of the mailing list for the GCC project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Strange g+ 3.1.1 double behavior

Gunther Weber wrote:

> while searching for a problem in one of my programs I ran across this
> strange gcc 3.1.1 beahvior:

>   std::cout << torus(0.0,0.0,10.0) -  torus(0.0,0.0,10.0) << std::endl;

> 3.85469e-13

> All this on a Celeron system running RedHat 7.3. Does anyone what could
> be causing this?  I would expect that both function calls with identical
> arguments would result in the same double value and thus in the programm
Not necesarily. floating point calculations can be performed at a
higher precision, and this happens on i86 hardware. IIRC the return value
will be in an i86 floating point register at 80 bits precision. One
return value must be stored on the stack (in a 64 bit double, hence
rounded), the other return value need not be, so is not rounded. The
result you see is the rounding error. This spilling of intermediates
at a lower precision is a quality of implementation thing.

-mfloat-store might help you here.


Dr Nathan Sidwell :: Computer Science Department :: Bristol University
           The voices in my head told me to say this

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]