Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

strictfp

 
Shanky Sohar
Ranch Hand
Posts: 1051
Eclipse IDE Firefox Browser
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Abimaran Kugathasan
Ranch Hand
Posts: 2066
Clojure IntelliJ IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.....
 
Deepak Bala
Bartender
Posts: 6663
5
Firefox Browser Linux MyEclipse IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This wiki link should help -> http://en.wikipedia.org/wiki/Strictfp#Usage

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

 
Shanky Sohar
Ranch Hand
Posts: 1051
Eclipse IDE Firefox Browser
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 2066
Clojure IntelliJ IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 19
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 2066
Clojure IntelliJ IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic