Float and Double arithmetic is only approximate. Try using BigDecimal.

-- padhu



Kenny G. Dubuisson, Jr. wrote:

>I am trying to output number in a formatted style and keep having strange
>behavior.  If I just output the float value, I get "9.9" for example.  If I
>format it to 3 decimals, I get "9.912"; it's adding values that aren't there
>in the actual number.  Here is what I get
>
>NumberFormat form = NumberFormat.getInstance();
>form.setMinimumIntegerDigits = 1;
>form.setMinimumFractionDigits = 3;
>form.setMaximumFractionDigits = 3;
>float myNumber = 9.9;
>String myNumberFormatted = form.format(myNumber);  //Output is "9.912"
>
>This absolutely makes no sense.  Anyone got any ideas?  Thanks,
>Kenny
>
>===========================================================================
>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
>
>
>

===========================================================================
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