The Artima Developer Community
Sponsored Link

Legacy Java Answers Forum
November 2000



This page contains an archived post to the Java Answers Forum made prior to February 25, 2002. If you wish to participate in discussions, please visit the new Artima Forums.


IEEE floating point operation

Posted by Albert on November 26, 2000 at 10:17 PM

i'm replying to myself after obtaining
more information about the subject.

this is not a bug, but how IEEE floating
point operates.

excerpt from a helpful respond :

With float and double values, if you want certain rounding behavior,
then you must provide for that in your code. The Java language does
not do any rounding by default. In fact, the Java Language Specification
(JLS) prohibits rounding by default. This surprises many people who are
familiar with the rounding done automatically by the C language run-time
This is not a problem with the Java Language.
All IEEE floating point arithmetic is inexact. This
is the inescapable consequence of storing the results
in a finite number of bits (32 for float and 64 for

You are operating at the limits of IEEE floating point accuracy.

As described in the standard: ANSI/IEEE STD 754-1985 (IEEE
Standard for Binary Floating-Point Arithmetic), when using
double values (which have roughly 18 decimal digits of
precision), every calculation introduces an error of about
1.0E-17. For float values (having about 8 decimal digits of
precision), every calculation introduces an error of at least


hope this help others that doesn't realize this already.


Sponsored Links

Copyright © 1996-2009 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use - Advertise with Us