Strictfp in java

Categories: Java // Tags: , , .
Email this to someonePrint this pageShare on Google+0Share on Facebook0Tweet about this on TwitterShare on LinkedIn0Share on Reddit0Pin on Pinterest0Share on StumbleUpon0

Strictfp keyword in java

Strictfp keyword in java 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.
Legal code:

The strictfp can be applied on methods, classes and interfaces.

Illegal code :

The strictfp can be applied on abstract methods, variables or constructors.

Examples

The following class is declared with strictfp, hence all the floating point computations within that class conform to IEEE’s 754 standard:

The following interface is declared with strictfp, but its methods cannot:

The following method is declared with strictfp:


 

Email this to someonePrint this pageShare on Google+0Share on Facebook0Tweet about this on TwitterShare on LinkedIn0Share on Reddit0Pin on Pinterest0Share on StumbleUpon0

About Team

Browse Archived Articles by Team