File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
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 | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
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://aspose.com/file-tools
 
subject: Loss of precision when converting int to float