Wiki Markup |
---|
The Java language provides two primitive types, {{float}} and {{double}}, which are associated with the single-precision 32-bit and double-precision 64-bit format IEEE 754 values and operations \[[IEEE 754|AA. Bibliography#IEEE 754 2006]\]. Each of the floating point types has a fixed, limited number of mantissa bits. Consequently, it is impossible to precisely represent any irrational number (for example, pi). Further, because these types use a binary mantissa, they cannot precisely represent many finite decimal numbers, such as 1/10, because these numbers have repeating binary representations. |
...
Wiki Markup |
---|
\[[Bloch 2008|AA. Bibliography#Bloch 08]\] Item 48: Avoid {{float}} and {{double}} if exact answers are required \[[Bloch 2005|AA. Bibliography#Bloch 05]\] Puzzle 2: Time for a Change \[[Goldberg 1991|AA. Bibliography#Goldberg 91]\] \[[IEEE 754|AA. Bibliography#IEEE 754 2006]\] \[[JLS 2005|AA. Bibliography#JLS 05]\] [Section 4.2.3|http://java.sun.com/docs/books/jls/third_edition/html/typesValues.html#4.2.3], "Floating-Point Types, Formats, and Values" |
...
03. Floating Point (FLP)NUM06-J. Provide mechanisms to handle unsigned data when required 03. Floating Point (FLP) Numeric Types and Operations (NUM) NUM08-J. Do not use denormalized numbers