For Programmers: Free Programming Magazines  


Home > Archive > Fortran > December 2004 > Re: small numerical differences in floating point result between









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author Re: small numerical differences in floating point result between
Jentje Goslinga

2004-12-16, 3:57 am



Dik T. Winter wrote:
> In article <pan.2004.12.15.13.46.45.172000@netactive.co.uk> Lawrence Kirby <lknews@netactive.co.uk> writes:
> ...
>
> Indeed. Is an expression like a * b + c indeed calculated with 53 bits
> mantissa only?


For Intel, as long as the compiler is able to hold an
expression or subexpression on the FPU stack, all operations
save for the two mentioned (FDIV,FSQRT) are in extended
precision.

Any time an expression or subexpression is saved to memory
or the subroutine's "stack frame", it is truncated to double
or single precision depending on the declaration of the
local variable.
Examining the compiler generated Assembler will reveal this
clearly. If the compiler is not so good it may save variables
to the stack frame unnecessarily or it may not make good use
of the available eight FPU stack registers.

Even the worst compiler will be able to evaluate your sample
expression in full accuracy since it requires precisely one
FPU stack slot (assuming one is free). Here is how the code
looks for double precision variables:

FLD qword ptr a
FMUL qword ptr b
FADD qword ptr c

Only the first operation loads something onto the FPU stack
but the other multiply resp add straight from memory into
the stack top.

This sort of question would also be expertly answered in the
newsgroup comp.lang.asm.x86

Jentje Goslinga

Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2009 codecomments.com