Post Reply 
FORTRAN floating point accuracy problems
04-07-2016, 02:28 PM
Post: #37
RE: FORTRAN floating point accuracy problems
(04-07-2016 01:36 PM)Werner Wrote:  - this is a case of wrong input (99 for seconds)
- the result is correct (try it on Free42 Decimal, for instance)

In decimal arithmetics everything is easy.

The point here is that already the binary representation of the argument may be off (or "wrong", as you put it). Consider the case dms=30,2 or 151/5. The closest possible binary double-precision representation of this translates to 30,199 99999 99999 993 in decimal notation. Even if you manually enter 30,2 the program will work with 30,1999... so that all the mentioned problems occur. Rounding (up) the input to 15 significant digits solves this.

(04-07-2016 01:36 PM)Werner Wrote:  BTW with x = 1e13/(5e13 + 1), on Free42 Binary, INT(100*x) delivers 19 and not 20 as you stated,

That's an easy case that is handled correctly even by Excel. Replace the "E13" part by E14 or E15, depending on Free42's working precision, so that the "+1" occurs in the least significant digit.

Dieter
Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
RE: FORTRAN floating point accuracy problems - Dieter - 04-07-2016 02:28 PM



User(s) browsing this thread: 2 Guest(s)