Why does division by zero with floating point (or double precision) numbers not throw java.lang.ArithmeticException: / by zero in Java

In short, that’s the way it’s specified in the IEEE-754 standard, which is what Java’s Floating-Point Operations are based on. Why doesn’t division by zero (or overflow, or underflow) stop the program or trigger an error? Why does a standard on numbers include “not-a-number” (NaN)? The 754 model encourages robust programs. It is intended not … Read more

ArithmeticException: “Non-terminating decimal expansion; no exact representable decimal result”

From the Java 11 BigDecimal docs: When a MathContext object is supplied with a precision setting of 0 (for example, MathContext.UNLIMITED), arithmetic operations are exact, as are the arithmetic methods which take no MathContext object. (This is the only behavior that was supported in releases prior to 5.) As a corollary of computing the exact … Read more