Two Laptop Bag
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Loss of precision when converting int to float Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Reply Bookmark "Loss of precision when converting int to float" Watch "Loss of precision when converting int to float" New topic
Author

Loss of precision when converting int to float

nishant vats
Greenhorn

Joined: Feb 11, 2005
Posts: 23
int k=944444444;
float f2=k;
System.out.println("f2 "+f2);
output is :f2 9.4444442E8

int k=94444444;
float f2=k;
System.out.println("f2 "+f2);
output is :f2 9.4444448E7

Note that in frist case there are 9 digits while in second case its 8 digits..
pls explain the output
 
I agree. Here's the link: http://zeroturnaround.com/jrebel - it saves me about five hours per week
 
subject: Loss of precision when converting int to float
 
Similar Threads
Wrapper class
float
Assignment doubt
Float and ==
whats the difference between float & double