What does 'strictfp' mean?
The keyword strictfp allows you to have more (predictable) control over floating-point arithmetic. Different arithmetic/logic units may enable additional features which allow a machine dependent answer to a floating point problem. The Java Virtual Machine has been modified to allow Java implementations to use these features where developers are not concerned with a routine, possibly providing a different, ie: more *or* less accurate solution to a problem on differing architectures.
Because many developers want the exact same solution to occur regardless of the underlying hardware, the strictfp keyword was implemented. strictfp insures that the VMS will always use a standardized implementation of floating point numbers, wherever the application/applet is run. Thus continuity across platforms is achieved. When this modifier is specified, the JVM adheres to the Java specifications ( IEEE-754 floating-point specification ) and returns the consistent value independent of the platform.
It can be used as a modifier with top-level classes, both static and non-static inner classes, inner interfaces, both static and instance method declarations. Variables, constructors, static or instance floating blocks can't have this modifier.
If an expression is FP-strict, all intermediate values should fit into the range for float or double variables, implying that the results of all FP-strict expressions must be those predicted by IEEE 754 arithmetic on operands represented using single and double formats. If an expression is not FP-strict, there are no such restrictions.
A non-constant expression is considered FP-strict if any of the class, interface or method declarations that contain the expression have the strictfp modifier.
References
15.4 FP-strict Expressions in JLS3
Updates to the Java Language Specification for JDK Release 1.2 Floating Point
Most Recent java Faqs
- How to avoid an java.util.ConcurrentModificationException with ArrayList?
- How to convert a given array to a list in Java?
- How to make Java objects eligible for garbage collection?
- What are local variables in Java?
- What are instance variables in Java?
- How many backslashes?
- What are class variables in Java?
Most Viewed java Faqs
- How to use HttpURLConnection POST data to web server?(24745)
- What is runtime polymorphism in Java?(18326)
- How to add BASIC Authentication into HttpURLConnection?(16083)
- What is String literal pool?(14754)
- Can the run() method be called directly to start a thread?(13991)
- What does Class.forname method do?(10593)
- Can transient variables be declared as 'final' or 'static'?(10445)