Since Java2, Java languages have added a keyword stricTFP, although this keyword is less used in most cases, but it is still necessary to understand.
Strictfp means fp-strict, that is, the meaning of precise floating point. When the Java virtual machine is floating, if there is no Strictfp keyword, Java's compiler, and the operating environment in the expression of floating-point operations are taken from the behavior of my line, so as to get these operations. The result is often unable to satisfy you. Once stricTFP is used to declare a class, interface, or method, then the Declaring Java compiler and the operating environment will be performed in accordance with floating point specification IEEE-754. So if you want your floating point operation more accurate, and will not consistent with the results executed by different hardware platforms, then use keyword stricTFP.
You can declare a class, interface, and method as stricTFP, but do not allow the method in the interface and constructor to declare the stricTFP keyword, such as the following code:
1. Legal use Keyword stricTFP
Strictfp interface a {} public stricTFP class fpdemo1 {strictfp void f ()}}
2. Wrong usage
Interface a {strictfp void f (); public class fpdemo2 {stricTFP fpdemo2 ()}}
Once the keyword stricTFP is used, when a class, interface, or method is used, all floating point calculations in the scope declared in this keyword are accurate, which is in line with the IEEE-754 specification. For example, a class is declared as stricTFP, then all methods in this class are stricTFP.