Knowledge baseExam Center
ENEnglish
Choose language13

CKTIS / Java

lang.StrictMath: practical reference

lang.StrictMath: practical reference: StrictMath provides reproducible core transcendental algorithms with specified fdlibm-based results where documented.

Version: Java SE 21 (JLS and Java SE API); examples verified on the repository Java runtime

Syntax

java.lang.StrictMath

StrictMath provides reproducible core transcendental algorithms with specified fdlibm-based results where documented.

Use StrictMath for numerical code that needs the specified reproducible results of its fdlibm-defined transcendental functions across Java implementations.

Only the documented functions have the special fdlibm reproducibility requirement. Integer overflow rules remain unchanged, and abs of MIN_VALUE is still negative.

NaN, infinities, and signed zero retain the method-specific IEEE 754 behavior. Exact integer helpers such as addExact throw ArithmeticException on overflow.

The example exercises the documented element in a small deterministic program and compares exact standard output.

Examples

public class Main {
    public static void main(String[] args) throws Exception {
        System.out.println(StrictMath.sqrt(81.0));
    }
}

Result

9.0

The example exercises the documented element in a small deterministic program and compares exact standard output.

Sources