aspose file tools*
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes strictfp Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "strictfp " Watch "strictfp " New topic
Author

strictfp

Shanky Sohar
Ranch Hand

Joined: Mar 17, 2010
Posts: 1051

from kathy ............

page no 46........

it can modify a class or method declaration, and that a variable can never be declared strictfp............


but in examlab.........the answer say..........strictfp can be used for instance variable and class.....


which one is correct


SCJP6.0,My blog Ranchers from Delhi
Abimaran Kugathasan
Ranch Hand

Joined: Nov 04, 2009
Posts: 2066

phil sohar wrote:from kathy ............

page no 46........

it can modify a class or method declaration, and that a variable can never be declared strictfp............


It's correct, If it is used for a method or a class, Strictfp ensures that you get exactly the same results from your floating point calculations on every platform. If you don't use strictfp, the JVM implementation is free to use extra precision where available.
phil sohar wrote:
but in examlab.........the answer say..........strictfp can be used for instance variable and class.....
which one is correct


Definitely strictfp can't be used for variable, I've done ExamLab, but I don't remember this answer, let see, what Devaka say.....


|BSc in Electronic Eng| |SCJP 6.0 91%| |SCWCD 5 92%|
Deepak Bala
Bartender

Joined: Feb 24, 2006
Posts: 6661
    
    5

This wiki link should help -> http://en.wikipedia.org/wiki/Strictfp#Usage

Did you try to add strictfp to a variable ? What happens ?



SCJP 6 articles - SCJP 5/6 mock exams - More SCJP Mocks
Shanky Sohar
Ranch Hand

Joined: Mar 17, 2010
Posts: 1051

Abimaran Kugathasan wrote:
Strictfp ensures that you get exactly the same results from your floating point calculations on every platform. If you don't use strictfp, the JVM implementation is free to use extra precision where available.



i didnot understand this.........please make it clear
Abimaran Kugathasan
Ranch Hand

Joined: Nov 04, 2009
Posts: 2066

phil sohar wrote:
i didnot understand this.........please make it clear


It's a IEEE(IEEE 754) standard to restrict floating point calculations. If you are a IEEE member, go here and login for further details. Normally floating point calculations are depends on platform, where you make calculations, but if you want to restrict those calculation to be same in all platforms, then you should go for strictfp, it's make those calculation in a standard way.

What Every Computer Scientist should know about floating point arithmetic

Anyway have Googling, you'll get better result than this
kavitha yogaraj
Greenhorn

Joined: Apr 21, 2010
Posts: 19
phil sohar wrote:from kathy ............

page no 46........

it can modify a class or method declaration, and that a variable can never be declared strictfp............


but in examlab.........the answer say..........strictfp can be used for instance variable and class.....


which one is correct
Another Interesting point is an Interface can be declared with strictfp but no interface can have strictfp declared method.
An Interface can be strictfp but not its methods.
Abimaran Kugathasan
Ranch Hand

Joined: Nov 04, 2009
Posts: 2066

kavitha yogaraj wrote:Another Interesting point is an Interface can be declared with strictfp but no interface can have strictfp declared method.
An Interface can be strictfp but not its methods.


If we declare strictfp to an interface, all the method will behave according to FP standards, we can't use abstract and strictfp together, it doesn't matter whether it's a class(abstract class) or interface.

But, there is a exception, for interface declaration only, we can use strictfp and abstract keywords together! Further details, look the Spec here
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: strictfp