Code Comments

Programming Forum and web based access to our favorite programming groups.
For Programmers: Free Programming Magazines | New: Database administration forum
Registration is free! Edit your profileCalendarFind other membersFrequently Asked QuestionsSearch -> 
Post New Thread











Thread
Author

Re: small numerical differences in floating point result between

websnarf@gmail.com wrote:
> Sun and Intel should produce identical results for
> negation,+,-,*,/,sqrt() operations, because this is required for IEEE
> 754 compliance, and both implement double and float on the same sized
> floating point values (older x86 compilers used to use 80bit for all FP
> temporaries which could definately be a source of differences, but VC++
> doesn't do this anymore).  You should also expect identical output for
> things like fprem(), ceil(), floor(), modf(), and so on.  All of these
> operations have well known and finite ways of being calculated to the
> best and closest possible result, which is what the IEEE 754 specifies.
> Results can be different if you put the processors into different
> rounding modes -- I thought that the ANSI C specification was supposed
> to specify a consistent rounding mode, so there shouldn't be any
> differences because of that, but I could be wrong.

Just for completeness (you probably know this), the "rounding
mode" of the Intel FPU affects only floating point square root
and division, FSQRT and FDIV, whereas the remaining transcendentals
 {FCOS,FSIN,FSINCOS,FPATAN,FPTAN,FYL2X,FY
L2XP1,F2XM1} as well as
FADD/FSUB and FMUL are always produced in extended precision at
no extra cost.
[This probably has to do with the fact that the ones affected
are computed using an iterative algorithm.]
As an earlier poster has noted this would require saving to memory
for every operations to adhere to IEEE which is clearly excessive,
unless it is specifically requested but that would produce really
inefficient code.

> The problem is everything else.  sin(), cos(), log(), exp(), atanh()
> etc, ... these guys are not even consistent between Athlons and
> Pentiums.

Is that so?

> The reason is that there is no known finite algorithm for
> computing these guys to the exactly corrected rounded result.  There
> are plenty of ways to compute them within an accuracy of "1 ulp"
> (i.e., off by at most one unit in the last siginificant bit.)

Not all of these functions are always provided by the hardware
by the way: On Intel, log has to be deduced from log2(x) or
log2(1+x) and exp(x) from (2^x)-1. Note that atanh is expressible
in other functions.

> But I am not the foremost expert on this stuff (and it looks like the
> other posters here know even less than me.)  This question is more
> appropriate for a group like comp.arch.arithmetic where there are
> plenty of posters there who are expert on this.
> --
> Paul Hsieh
> http://www.pobox.com/~qed/
> http://bstring.sf.net/

Jentje Goslinga


Report this thread to moderator Post Follow-up to this message
Old Post
Jentje Goslinga
12-15-04 02:01 AM


Sponsored Links




Last Thread Next Thread Next
Search this forum -> 
Post New Thread

Fortran archive

Show a Printable Version Send to friend Email This Page to Someone! subscribe to this thread Receive updates to this thread
Computer Consultants
Programming Jobs
Visual Basic Controls
SQL Server Programming
Webservices
Java Security
Visual Studio
C# Programming
Visual J++
Software engineering
Open source Software
Perl Programming
PHP Programming
ASP Programming
ASP .NET Programming
Visual Basic Programming
Windows Scripting Host
Java Programming
Java Help
Java Beans
VBScript
Cobol
MAC Applications
Unix Programming
Forum Jump:
All times are GMT. The time now is 03:59 AM.

 
Free MCSE Braindumps | Real Estate Topics

Programming forum archive

Copyrights CodeComments.com 2004 - 2006

Powered by vBulletin Copyright 2000-2006 Jelsoft Enterprises Limited.