The below mentioned code should give you the result you are looking for :
import java.text.*;
public class testD
{
public static void main(String args[])
{
float d1=99.44f;
float d2=99.40f ;
float d3=d1-d2 ;
DecimalFormat df = new DecimalFormat("0.00");
System.out.println(df.format(d3));
}
}
Hope this helps :-).
Have a nice day.
With regards,
Sachin S. Khanna
http://www.emailanorder.com
----- Original Message -----
From: lancelot <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Friday, June 29, 2001 2:11 PM
Subject: Need your help one float and double calc.
> Dear all,
> Who can tell me why the result is 0.040000916? and why it's not =
> 0.04, if I want to get 0.04 how could I do? thanks
>
> Lancelot
>
> D:\test>type testD.java
> public class testD
> {
> public static void main(String args[])
> {
> float d1=3D99.44f;
> float d2=3D99.40f ;
> float d3 =3D d1-d2 ;
> System.out.println(d3);
> }
> }
>
>
> D:\test>java testD
> 0.040000916
>
>
===========================================================================
> 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://java.sun.com/products/jsp/faq.html
> http://www.esperanto.org.nz/jsp/jspfaq.html
> http://www.jguru.com/jguru/faq/faqpage.jsp?name=JSP
> http://www.jguru.com/jguru/faq/faqpage.jsp?name=Servlets
>
===========================================================================
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://java.sun.com/products/jsp/faq.html
http://www.esperanto.org.nz/jsp/jspfaq.html
http://www.jguru.com/jguru/faq/faqpage.jsp?name=JSP
http://www.jguru.com/jguru/faq/faqpage.jsp?name=Servlets