Velocity Reviews > C++ > small numerical differences in floating point result between wintel and Sun/SPARC

# small numerical differences in floating point result between wintel and Sun/SPARC

James Giles
Guest
Posts: n/a

 12-20-2004
Victor Bazarov wrote:
> Merrill & Michele wrote:

....
>> Does the Standard have anything to say about machine epsilon? MPJ

>
> Which Standard do you mean to ask about? You cross-posted to three
> different language newsgroups. The C++ Standard says that the member
> 'epsilon' of 'std::numeric_limits' returns the difference between 1
> and the least value greater than 1 that is representable. It does not
> say specify the actual value returned from 'epsilon'. The C Standard
> does give the maximum acceptable values of 'FLT_EPSILON', 'DBL_EPSILON'
> and 'LDBL_EPSILON', but your implementation is free to provide its own,
> smaller values. And I have no idea about the Fortran Standard.

Fortran has a generic intrinsic function called EPSILON. The
following code prints the values of the machine epsilon for single
and double precision:

Print *, epsilon(1.0), epsilon(1.0d0)
End

The return value is b^(1-p), where b is the base of the floating point
numbers (usually 2) and p is the number of base-b digits in the significand
(including any hidden normalization digit). For IEEE single, the result
is 2^(-23). For IEEE double, the result is 2^(-52). Note that the result
doesn't depend on the argument's value, only it's type attributes, so
EPSILON(0.0) returns the same result as EPSILON(1.0), since both
arguments are default precision reals. If the implementation were to
the same inquiry function could be applied to them. Similarly, if
an implementation were to support the proposed IEEE decimal
floating point, the same inquiry function could be applied to those
as well. The result is in the same floating-point precision (and
base) as the argument.

--
J. Giles

"I conclude that there are two ways of constructing a software
design: One way is to make it so simple that there are obviously
no deficiencies and the other way is to make it so complicated
that there are no obvious deficiencies." -- C. A. R. Hoare

CBFalconer
Guest
Posts: n/a

 12-20-2004
Merrill & Michele wrote:
>

.... snip ...
>
> Does the Standard have anything to say about machine epsilon? MPJ

c:\dnld>grep -n epsilon \stds\n869.txt
28465: epsilon FLT_EPSILON, DBL_EPSILON, LDBL_EPSILON

Now is that so hard you couldn't do it for yourself?

--
Chuck F ((E-Mail Removed)) ((E-Mail Removed))
Available for consulting/temporary embedded and systems.

 Posting Rules You may not post new threads You may not post replies You may not post attachments You may not edit your posts BB code is On Smilies are On [IMG] code is On HTML code is OffTrackbacks are On Pingbacks are On Refbacks are Off Forum Rules

 Similar Threads Thread Thread Starter Forum Replies Last Post Saraswati lakki ASP .Net 0 01-06-2012 06:39 AM Home_Job_opportunity C Programming 0 01-14-2009 03:51 PM Home_Job_opportunity C Programming 0 01-08-2009 04:31 PM teeshift Ruby 2 12-01-2006 01:16 AM JS C Programming 30 12-20-2004 08:55 PM