Meaningless Drivel is fun!*
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Floating point operations 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 "Floating point operations" Watch "Floating point operations" New topic
Author

Floating point operations

Binu K Idicula
Ranch Hand

Joined: Jul 11, 2002
Posts: 99
System.out.println(Float.MIN_VALUE+1);
System.out.println(Float.MIN_VALUE);
System.out.println(Float.MIN_VALUE-1);
yeilded
1.0
1.4E-45
-1.0
where can I get some short notes on floating point operations?
Your help needed .. ..
Ron Newman
Ranch Hand

Joined: Jun 06, 2002
Posts: 1056
One thing to keep in mind here is that Float.MIN_VALUE is the smallest positive value representable as a float. This is very different from Integer.MIN_VALUE which is a large negative number. I wish the designers of Java hadn't used the same name to mean two very different things.
Floating point numbers have a limited amount of precision. If you add Float.MIN_VALUE (1e-45) to either 1 or -1, you will lose precision because there aren't enough bits available to represent 46 decimal places of precision.


Ron Newman - SCJP 1.2 (100%, 7 August 2002)
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Floating point operations