Dwayne,
What an odd question! A floating point number is a finite representation of
a real number. It can only capture a finite number of distinct real numbers
with complete precision. Any education in programming regardless of how
formal or informal should include this.
Java floats, which are based on the IEEE 754 standard, have 23 bits of
so-called mantissa. This corresponds to a precision of not quite 7 decimal
digits. This means that the error observed by Mr. Kenny G. Dubuisson, Jr.
could not be the result of the limited precision of Java float values.
I ran the following program under Java 1.4.1 on Windows 2000 Pro:
-==--==--==--==--==--==--==--==--==--==-
import java.text.NumberFormat;
public
class JFT
{
public
static
void
main(String[] args)
{
NumberFormat form = NumberFormat.getInstance();
form.setMinimumIntegerDigits(1);
form.setMinimumFractionDigits(3);
form.setMaximumFractionDigits(3);
float myNumber = (float) 9.9;
String myNumberFormatted = form.format(myNumber);
System.out.println(myNumberFormatted);
}
}
-==--==--==--==--==--==--==--==--==--==-
Running this program produces the output "9.900"
This is what I'd expect.
Randall Schulz
Mountain View, CA USA
At 12:39 2002-10-11, you wrote:
>Padhu Vinirs [mailto:[EMAIL PROTECTED]] wrote:
>
> > Float and Double arithmetic is only
> > approximate. Try using BigDecimal.
>
>Yow... I never read that anywhere. That is good information. Is it
>documented *anywhere* ??
>
>Dwacon
>www.dwacon.com
===========================================================================
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