strictfp in Java 2

By: Baski Printer Friendly Format    

Java 2 adds a new keyword to the Java language, called strictfp. With the creation of Java 2, the floating point computation model was relaxed slightly to make certain floating point computations faster for certain processors, such as the Pentium. Specifically, the new model does not require the truncation of certain intermediate values that occur during a computation. By modifying a class or a method with strictfp, you ensure that floating point calculations (and thus all truncations) take place precisely as they did in earlier versions of Java. The truncation affects only the exponent of certain operations. When a class is modified by strictfp, all the methods in the class are also modified by strictfp automatically.

For example, the following fragment tells Java to use the original floating point model for calculations in all methods defined within MyClass:

strictfp class MyClass { //...

Frankly, most programmers never need to use strictfp, because it affects only a very small class of problems.

Most Viewed Articles (in Java )

Latest Articles (in Java)

Comment on this tutorial

Subscribe to Tutorials

Related Tutorials

Archived Comments

1. Hi, It is not clear from the answer. What I unders
View Tutorial          By: amar at 2010-12-25 08:02:39

2. Hello,
I would like to know how will take p

View Tutorial          By: Jeff at 2011-02-02 23:05:17

3. if the two StringBuffer object contain same String
View Tutorial          By: Avinash kumar at 2011-11-09 11:16:19

4. float f=1.2351111f;

View Tutorial          By: jack at 2011-11-10 11:49:00

5. because equals method compares on object reference
View Tutorial          By: mohit s. at 2011-12-24 06:29:35

6. How to sort an Arraylist in some given order? Say,
View Tutorial          By: Arunava Chatterjee at 2015-03-07 04:17:51