File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Beginning Java and the fly likes strictfp Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Java Interview Guide this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "strictfp" Watch "strictfp" New topic


Jitendra Jha
Ranch Hand

Joined: Jan 28, 2007
Posts: 91
What is strictfp?
where is it used?Please suggest a case where we can use it!!

Thanks in advance:

Gavin Tranter
Ranch Hand

Joined: Jan 01, 2007
Posts: 333
Hi, it forces floating point numbers to adhere to an IEEE 754 standard, that is independent of platform.
It is a modifer, for classes and methods, but NOT for variables.

You should be able to find details of it within JavaDoc, and details of the standard itself from the IEEE.

You would use it when you would want to ensure consistant floating point operation/evaluation across platforms.

[ February 21, 2007: Message edited by: Gavin Tranter ]
Keith Lynn
Ranch Hand

Joined: Feb 07, 2005
Posts: 2398
strictfp is a modifier used on classes and methods that requires all calculations within the class or method to adhere to IEEE 754.
Jitendra Jha
Ranch Hand

Joined: Jan 28, 2007
Posts: 91
What is IEEE 754?
Ulf Dittmer

Joined: Mar 22, 2005
Posts: 42965
IEEE 754 is a standard for performing binary floating point calculations: Wikipedia: IEEE 754
fred rosenberger
lowercase baba

Joined: Oct 02, 2003
Posts: 11957


You may want to read our FAQ on How To Ask Questions. Finding what IEEE 754 standard is something that would have taken about 5 seconds to find with google.

Once you find it, if you don't understand it then feel free to ask about that. However simply posting a question without even attempting to find the answer wastes a lot of people's time.

There are only two hard things in computer science: cache invalidation, naming things, and off-by-one errors
Ilja Preuss

Joined: Jul 11, 2001
Posts: 14112
With non-strict floating point arithmetic (the standard in Java), you can get slightly different results on different platforms.

As a contrived example, as a result of a complex expression you could get 1.23456789 on one platform, but 1.23456788 on another.

If you need the exact same results on all platforms, you use strictfp. Doing so can reduce performance on some platforms, though.

The soul is dyed the color of its thoughts. Think only on those things that are in line with your principles and can bear the light of day. The content of your character is your choice. Day by day, what you do is who you become. Your integrity is your destiny - it is the light that guides your way. - Heraclitus
Jitendra Jha
Ranch Hand

Joined: Jan 28, 2007
Posts: 91
"Ilja Preuss"

Thanks for help.That solved my doubt!!!
I agree. Here's the link:
subject: strictfp
It's not a secret anymore!