 This topic has 6 replies on 1 page. 


Posts:236 Registered: 5/11/04  significant digits Aug 4, 2004 1:31 AM 

 double has a range of �1.79769313486231570e+308, and with 14 to 15 significant digits of accuracy.
if it has only 1415 digits of accuracy, does this mean that the 16th digit in a decimal number of a double value is not accurate or is negligible?
thanks in advance.  
Posts:441 Registered: 2/25/04  Re: significant digits Aug 4, 2004 2:06 AM (reply 1 of 6) 

 if it has only 1415 digits of accuracy, does this mean that the 16th digit in a decimal number of a double value is not accurate or is negligible? Each floating point value represents a segment of the real number line, the length of this segment being 2 ^ exponent / 2^no.mantissa bits. Whether this translates to a 14th or 15th digit depends on the number. Whether you interpret the length of this segment as negligible or inaccurate depends on the semantics you are attaching to the value, not the value itself. If you are doing 3D visualisation, then any intensity graduation below one part in a thousand is negligible; if you're compulting the difference between two very close floating point numbers, the interaction of their ranges will cause an error. Pete  
Posts:4,496 Registered: 19/06/02  Re: significant digits Aug 4, 2004 2:11 AM (reply 2 of 6) 

 This is covered in the JLS. A compiletime error occurs if a nonzero floatingpoint literal is too large, so that on rounded conversion to its internal representation it becomes an IEEE 754 infinity. A program can represent infinities without producing a compiletime error by using constant expressions such as 1f/0f or 1d/0d or by using the predefined constants POSITIVE_INFINITY and NEGATIVE_INFINITY of the classes Float and Double. Basically, overflow produces infinity.  
Posts:5,965 Registered: 5/17/03  Re: significant digits Aug 4, 2004 2:37 AM (reply 3 of 6) 

 A double has about 17 digits of accuracy. (not after the comma but as a whole). All those digits are accurate but the last one has been rounded. A float has about 7 digits.  
Posts:236 Registered: 5/11/04  Re: significant digits Aug 4, 2004 2:48 AM (reply 4 of 6) 

 A double has about 17 digits of accuracy. (not after the comma but as a whole). All those digits are accurate but the last one has been rounded. A float has about 7 digits. but, why is it that if i have a double value as below, double d1 = 0.001233454546567677676; then using System.out.println to output it, the result is as below, "0.0012334545465676778" which has more than 17 digits. does this mean that the remaining digits are not accurate? thanks  
Posts:4,496 Registered: 19/06/02  Re: significant digits Aug 4, 2004 2:57 AM (reply 5 of 6) 

 Look at the toString(double) method:
http://java.sun.com/j2se/1.4.2/docs/api/java/lang/Double.html  
Posts:5,965 Registered: 5/17/03  Re: significant digits Aug 4, 2004 2:58 AM (reply 6 of 6) 

 "0.0012334545465676778" which has more than 17 digits. Not really. You have, 1.2334545465676778 E3 Which is 17 digits of precision.  