Core Java - operation with double primitive type
0 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   ShadowFax
Posted On:   Tuesday, June 24, 2014 08:30 AM

Hi,   I have executed the following code on Java.SE-1.7. I wonder why is the output of the last SOP false. The different values i used are 5.705, 11.41, 22.82...   public class MyTest {   public static void main(String[] args) { // TODO Auto-generated method stub double a = 5.705; double b = 1.5; double c = a*b;   System.out.println((a*b)); System.out.println(c/1.5); System.out.println(a == c/b); }   }     Output: ---------   8.557500000000001 5.705000000000001 false    More>>
Hi,
 
I have executed the following code on Java.SE-1.7. I wonder why is the output of the last SOP false. The different values i used are 5.705, 11.41, 22.82...
 
public class MyTest {
 
public static void main(String[] args) {
// TODO Auto-generated method stub
double a = 5.705;
double b = 1.5;
double c = a*b;
 
System.out.println((a*b));
System.out.println(c/1.5);
System.out.println(a == c/b);
}
 
}
 
 
Output:
---------
 
8.557500000000001
5.705000000000001
false
   <<Less
About | Sitemap | Contact