Java uses IEEE (Institute of Electronics and Electrical Engineers) Standard 754 to store real numbers. While knowledge of the standard may no longer be crucial for programmers due to abstraction of this detail it is placed here for completeness and as a reference in case the need arises to parse raw data and the result is not as expected. IEEE 754 Applet.
Related Articles:From: "The Java Virtual Machine Specification" at
http://java.sun.com/docs/books/vmspec/2nd-edition/html/Concepts.doc.html#33377From: "The Java Language Specification" at
http://java.sun.com/docs/books/jls/second_edition/html/lexical.doc.html#230798From: "The Java API"
http://java.sun.com/j2se/1.4/docs/api/java/lang/Float.html
http://java.sun.com/docs/books/vmspec/2nd-edition/html/Concepts.doc.html#33377From: "The Java Language Specification" at
http://java.sun.com/docs/books/jls/second_edition/html/lexical.doc.html#230798From: "The Java API"
http://java.sun.com/j2se/1.4/docs/api/java/lang/Float.html
IEEE 754:The IEEE 754 Standard uses 1-plus form of the binary normalized fraction (rounded). The fraction part is called the mantissa.
1-plus normalized scientific notation base two is then
1-plus normalized scientific notation base two is then
N = ± (1.b1b2b3b4 ...)2 x 2+E
The 1 is understood to be there and is not recorded.
The Java primitive data type float is 4 bytes, or 32 bits:
The Java primitive data type float is 4 bytes, or 32 bits:
1 bit Sign | 8 bit exponent | 23 bit mantissa |
While the double is 8 bytes, or 64 bits, formatted as follows: