• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Surprising output,can't understood.

 
Ashok Pradhan
Ranch Hand
Posts: 180
Eclipse IDE Firefox Browser Netbeans IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
When i run the following program it prints 12.123457 and please explain this why 12.123457.
 
Harshit Rastogi
Ranch Hand
Posts: 131
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
when a values is assigned to Float class , internally it stores to the float primitive. So i guess the precision of the primitive float comes into the picture.
If somebody can throw some more light !!
 
Mohammed Yousuff
Ranch Hand
Posts: 198
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
as Harshit said this is more to deal with memory allocated with the floating point variable....

any more thoughts ....
 
marc weber
Sheriff
Posts: 11343
Java Mac Safari
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
That's exactly right. This loss of precision is a result of how floating-point values are stored.

See Some things you should know about floating-point arithmetic.
[ April 20, 2008: Message edited by: marc weber ]
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic