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.
Message:
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 runtime library. ... 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 double). You are operating at the limits of IEEE floating point accuracy. As described in the standard: ANSI/IEEE STD 7541985 (IEEE Standard for Binary FloatingPoint Arithmetic), when using double values (which have roughly 18 decimal digits of precision), every calculation introduces an error of about 1.0E17. For float values (having about 8 decimal digits of precision), every calculation introduces an error of at least 1.0E7.  hope this help others that doesn't realize this already.
Replies:
 rounding Carlos March 17, 2001 at 10:38 PM
(1)
