Java Strictfp关键字
Java strictfp关键字可确保在浮点变量中执行操作时,在每个平台上都能获得相同的结果。精度因平台而异,这就是Java编程语言提供了strictfp关键字的原因,因此您在每个平台上都得到相同的结果。因此,现在您可以更好地控制浮点算法了。
strictfp关键字的法律代码
strictfp关键字可以应用于方法,类和接口。
strictfp class A{
}
//strictfp applied on class
strictfp interface M{
}
//strictfp applied on interface
class A{
strictfp void m(){
}
//strictfp applied on method}
strictfp关键字的非法代码
strictfp关键字
不能应用于抽象方法,变量或构造函数。
class B{
strictfp abstract void m();
//Illegal combination of modifiers}
class B{
strictfp int data=10;
//modifier strictfp not allowed here}
class B{
strictfp B(){
}
//modifier strictfp not allowed here}