...
However, if the platform provides extended floating-point support, this program might print a numeric result roughly equivalent to Double.MAX_VALUE
.
JVM implementations are not required to report an overflow resulting from the initial multiplication, although they can The initial multiplication might overflow, but is not required to. The JVM may choose to treat this case as strictfp
; if it soes so, overflow occurs. The ability to use extended exponent ranges to represent intermediate values is implementation-defined.
Code Block | ||
---|---|---|
| ||
class Example { public static void main(String[] args) { double d = Double.MAX_VALUE; System.out.println("This value \"" + ((d * 1.1) / 1.1) + "\" cannot be represented as double."); } } |
...
Code Block | ||
---|---|---|
| ||
class Example {
double d = 0.0;
public void example() {
float f = Float.MAX_VALUE;
float g = Float.MAX_VALUE;
this.d = f * g;
System.out.println("d (" + this.d + ") might not be equal to " + (f * g));
}
public static void main(String[] args) {
Example ex = new Example();
ex.example();
}
}
|
...
<ac:structured-macro ac:name="unmigrated-wiki-markup" ac:schema-version="1" ac:macro-id="e9305d420427ea60-ed1c6cb7-4fdf4bbb-815090ba-c6517afaa15bdd4a9dd976e2"><ac:plain-text-body><![CDATA[ | [[Darwin 2004 | AA. Bibliography#Darwin 04]] | Ensuring the Accuracy of Floating-Point Numbers | ]]></ac:plain-text-body></ac:structured-macro> | |
<ac:structured-macro ac:name="unmigrated-wiki-markup" ac:schema-version="1" ac:macro-id="edf8f42229865970-52e9de8a-49b24f70-952690e6-c4965d0137916be9b4e20c16"><ac:plain-text-body><![CDATA[ | [[JLS 2005 | AA. Bibliography#JLS 05]] | [§15.4, "FP-strict Expressions" | http://java.sun.com/docs/books/jls/third_edition/html/expressions.html#15.4] | ]]></ac:plain-text-body></ac:structured-macro> |
<ac:structured-macro ac:name="unmigrated-wiki-markup" ac:schema-version="1" ac:macro-id="75c0ec76c2ebd189-1c9aadbc-43e64585-bc87be12-b1c91392639cc67666387938"><ac:plain-text-body><![CDATA[ | [[JPL 2006 | AA. Bibliography#JPL 06]] | 9.1.3. Strict and Non-Strict Floating-Point Arithmetic | ]]></ac:plain-text-body></ac:structured-macro> | |
<ac:structured-macro ac:name="unmigrated-wiki-markup" ac:schema-version="1" ac:macro-id="59fbc80dfeac5c0e-a48b0b11-4da24a26-95658889-110970253751600b5fbc902a"><ac:plain-text-body><![CDATA[ | [[McCluskey 2001 | AA. Bibliography#McCluskey 01]] | Making Deep Copies of Objects, Using strictfp, and Optimizing String Performance | ]]></ac:plain-text-body></ac:structured-macro> |
...