---
spec: JLS
title: "The Java Language Specification"
edition: "Java SE 16 Edition"
java_version: 16
chapter: "Chapter 15. Expressions"
section: "15.4"
heading: "15.4. FP-strict Expressions"
parent: "Chapter 15. Expressions"
source: https://docs.oracle.com/javase/specs/jls/se16/html/jls-15.html#jls-15.4
id: "15.4"
url: https://jvm.obfuscated.software/jls/se16/15.4.html
raw: https://jvm.obfuscated.software/jls/se16/15.4.md
---

# 15.4. FP-strict Expressions

If the type of an expression is `float` or `double`, then there is a question as to what value set ([§4.2.3](4.2.3.md)) the value of the expression is drawn from. This is governed by the rules of value set conversion ([§5.1.13](5.1.13.md)); these rules in turn depend on whether or not the expression is *FP-strict*.

Every constant expression ([§15.29](15.29.md)) is FP-strict.

If an expression is not a constant expression, then consider all the class declarations, interface declarations, and method declarations that contain the expression. If *any* such declaration bears the `strictfp` modifier ([§8.1.1.3](8.1.1.3.md), [§8.4.3.5](8.4.3.5.md), [§9.1.1.2](9.1.1.2.md)), then the expression is FP-strict.

If a class, interface, or method, X, is declared `strictfp`, then X and any class, interface, method, constructor, instance initializer, static initializer, or variable initializer within X is said to be *FP-strict*.

Note that an annotation's element value ([§9.7](9.7.md)) is always FP-strict, because it is always a constant expression.

It follows that an expression is not FP-strict if and only if it is not a constant expression *and* it does not appear within any declaration that has the `strictfp` modifier.

Within an FP-strict expression, all intermediate values must be elements of the float value set or the double value set, implying that the results of all FP-strict expressions must be those predicted by IEEE 754 arithmetic on operands represented using binary32 and binary64 floating-point formats.

Within an expression that is not FP-strict, some leeway is granted for an implementation to use an extended exponent range to represent intermediate results; the net effect, roughly speaking, is that a calculation might produce "the correct answer" in situations where exclusive use of the float value set or double value set might result in overflow or underflow.
