This week's book giveaway is in the Mac OS forum.
We're giving away four copies of a choice of "Take Control of Upgrading to Yosemite" or "Take Control of Automating Your Mac" and have Joe Kissell on-line!
See this thread for details.
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
 
GeeCON Prague 2014
 
subject: Loss of precision when converting int to float