strictfp

strictfp is a Java keyword that restricts floating-point calculations in order to ensure portability.

strictfp

strictfp

     

strictfp is a Java keyword that restricts floating-point calculations in order to ensure portability. The modifier was added to the Java programming language with the Java virtual machine version 1.2.

Older versions of JVMs were always use strict floating-point, means all values used during floating-point calculations are made in the IEEE-standard float or double sizes. This sometimes result in a numeric overflow or underflow during calculation, even if the end result would be a valid number. However JVM 1.2, does not restrict to all the numbers used in floating-point calculations limited to the standard float or double precision.

While some applications, might require having precisely the same floating-point behavior for every platform, even if some platforms could handle more precision. In such situations, a programmer is free to use the modifier strictfp to make sure that calculations are performed as in the earlier versions?only with floats and doubles.

The modifier can be combined with classes, interfaces and methods.

Strict floating point behavior are typically used by compile-time constant expressions. While other expressions use strict floating-point math whenever they are contained in a method, interface, or class which uses the strictfp modifier in its declaration.