• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Loss of precision when converting int to float

 
nishant vats
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic