Post Reply 
FORTRAN floating point accuracy problems
05-03-2016, 02:56 PM
Post: #49
RE: FORTRAN floating point accuracy problems
(05-03-2016 01:02 PM)HP67 Wrote:  It would be nice if there were some way of determining safedigits environmentally, without having to code a constant, so the code would be somewhat portable.

Some languages feature a function that returns the smalles possible machine epsilon. Others could use something like this:

Code:
Function safedigits()

e = 1.0   ' e has the data type for which we want to know the number of valid decimal digits

Do While 1.0 + e > 1.0
   e = e * 0.5
Loop

safedigits = Int(-Log10(e))

End Function

However, things may be slightly different with base-16 encoded numbers like the ones used by your hardware: cf. here.

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 - 05-03-2016 02:56 PM



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