i'm confused with the explanation given.Can some one explain this little more
Thanks in Advance Chandrasekhar S SCJP [ June 18, 2004: Message edited by: Chandrasekhar S ]
"Luck is when opportunity meets preparation"
Joined: Jun 08, 2004
Check out the round method in the Math class.
Hint: Temporarily move the decimal over two spots while you round.
Joined: Mar 18, 2003
The problem is that a float and double are each stored as two parts, a mantissa and an exponent and that they are each in terms of powers of two. It's the exponent that gives floating point such a wide range, but at the expense of mantissa accuracy. I think that mantissa float accuracy is about 24 binary bits and about 48 bits for double. If you divide those by 3 (a very rough guide), you get about 8 and 16 decimal digit accuracy. Iow, you should not depend on more than about 6 or 14 bit accuracy respectively for each one. Use the format classes to produce no more than the required number of digits. [ June 19, 2004: Message edited by: Eddie Vanda ]
The nice thing about Standards is that there are so many to choose from!