Approximate numeric datatypes, used to store floating-point numbers, are inherently 
slightly inaccurate in their representation of real numbers—hence the name 
"approximate numeric". In order to use these datatypes, you must understand and accept 
their limitations. 
Any time a floating-point number is printed or displayed, the printed representation 
is not quite the same as the stored number, and the stored number is not quite the 
same as the number that the user entered. Most of the time, the stored representation 
is close enough, and software makes the printed output look just like the original 
input, but you must understand the inaccuracy if you plan to use floating-point 
numbers for calculations, particularly if you will be doing repeated calculations 
using approximate numeric datatypes—the results can be surprisingly and unexpectedly 
inaccurate. 
The inaccuracy occurs because floating-point numbers are stored in the computer as 
binary fractions (that is, as a representative number divided by a power of 2), but 
the numbers we use are decimal (powers of 10). This means that only a very small set 
of numbers can be stored accurately: 0.75 (3/4) can be stored accurately because it is 
a binary fraction (4 is a power of 2); 0.2 (2/10) can not (10 is not a power of 2). 
Some numbers contain too many digits to store accurately. double precision is stored 
as 8 binary bytes and can represent about 17 digits with reasonable accuracy; real is 
stored as 4 binary bytes and can represent only about 6 digits with reasonable 
accuracy. 
As you can see, if you begin with numbers that are almost right, and do computations 
with them using other numbers that are almost right, you can easily end up with a 
result that is not even close. If these considerations are important to your 
application, consider using an exact numeric datatype. 

You can tell it's Friday!!! Have a great weekend. I've got a 3 Dayer thanx to State 
Government! ;)
Keith
Keith E. Kosmicki
Applications Consultant
State of IL Human Services
STL Technology Partners

==========================================================================To 
unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff JSP-INTEREST".
For digest: mailto [EMAIL PROTECTED] with body: "set JSP-INTEREST DIGEST".
Some relevant FAQs on JSP/Servlets can be found at:

 http://archives.java.sun.com/jsp-interest.html
 http://java.sun.com/products/jsp/faq.html
 http://www.esperanto.org.nz/jsp/jspfaq.jsp
 http://www.jguru.com/faq/index.jsp
 http://www.jspinsider.com

Reply via email to