aspose file tools*
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Surprising output,can't understood. 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 "Surprising output,can Watch "Surprising output,can New topic
Author

Surprising output,can't understood.

Ashok Pradhan
Ranch Hand

Joined: Dec 17, 2007
Posts: 180

When i run the following program it prints 12.123457 and please explain this why 12.123457.
Harshit Rastogi
Ranch Hand

Joined: Apr 15, 2008
Posts: 131
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 !!


My Techie Blog - Java Questions
Mohammed Yousuff
Ranch Hand

Joined: Oct 17, 2007
Posts: 198
as Harshit said this is more to deal with memory allocated with the floating point variable....

any more thoughts ....


My Thoughts : http://passion4java.blogspot.com
Try not to become a man of success but rather to become a man of value.
marc weber
Sheriff

Joined: Aug 31, 2004
Posts: 11343

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 ]

"We're kind of on the level of crossword puzzle writers... And no one ever goes to them and gives them an award." ~Joe Strummer
sscce.org
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Surprising output,can't understood.