Help with float numbers in Java

Posted by Alvin on Stack Overflow See other posts from Stack Overflow or by Alvin
Published on 2010-05-29T18:50:04Z Indexed on 2010/05/29 18:52 UTC
Read the original article Hit count: 195

Filed under:
|
|

Hi, Could anyone please me why the output of the following programme is not " different different"?

public static void main(String[] args)
{

float f1=3.2f;
float f2=6.5f;

if(f1==3.2)
System.out.println("same");
else
System.out.println("different");

if(f2==6.5)
System.out.println("same");
else
System.out.println("different");
}

o/p :different same

© Stack Overflow or respective owner

Related posts about java

Related posts about float