Java Strictfp Keyword
Chapter:
Miscellaneous
Last Updated:
24-03-2017 04:16:05 UTC
Program:
/* ............... START ............... */
strictfp class A{}//strictfp applied on class
strictfp interface M{}//strictfp applied on interface
class A{
strictfp void m(){}//strictfp applied on method
}
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
}
/* ............... END ............... */
Notes:
-
strictfp means strict floating point, ensures that you get exactly the same results from your floating point calculations on every platform.
- Java strictfp keyword ensures that you will get the same result on every platform if you perform operations in the floating-point variable. The precision may differ from platform to platform that is why java programming language have provided the strictfp keyword, so that you get same result on every platform. So, now you have better control over the floating-point arithmetic.
- The strictfp keyword cannot be applied on abstract methods, variables or constructors.
- strictfp forces floating points (and any floating-point operations) to adhere to the IEEE 754 standard., so that floating point results are always same on any platform.
Tags
Strictfp Keyword, Java, Miscellaneous