• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Devaka Cooray
  • Ron McLeod
  • Jeanne Boyarsky
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Piet Souris
  • Carey Brown
  • Tim Holloway
Bartenders:
  • Martijn Verburg
  • Frits Walraven
  • Himai Minh

about reserved keyword.

 
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi, everyone:
Please tell why strictfp is reserved keyword.
For example:

int strictfp = 10; will not compile with the error message:
test/Test.java [31:1] Variable or method name expected
int strictfp = 10;
^
1 error
Thanks in advance.
guoqiao
 
Ranch Hand
Posts: 65
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hey , where are u writing this declaration ?
i mean which part of the body ............

regards
 
mister krabs
Posts: 13974
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
strictfp has to do with certain types of conversions between int/long and float/double.
strictfp is a class and method modifier. A method declared native can not also be declared strictfp. strictfp can not be used as a constructor modifier. strictfp can be used as a modifier for interfaces but it can not be used as a method modifier in an interface.


15.4 FP-strict Expressions
If the type of an expression is float or double, then there is a question as to what value set (�4.2.3) the value of the expression is drawn from. This is governed by the rules of value set conversion (�5.1.8); these rules in turn depend on whether or not the expression is FP-strict.
Every compile-time constant expression (�15.28) is FP-strict. If an expression is not a compile-time constant expression, then consider all the class declarations, interface declarations, and method declarations that contain the expression. If any such declaration bears the strictfp modifier, then the expression is FP-strict.
If a class, interface, or method, X, is declared strictfp, then X and any class, interface, method, constructor, instance initializer, static initializer or variable initializer within X is said to be FP-strict.
It follows that an expression is not FP-strict if and only if it is not a compile-time constant expression and it does not appear within any declaration that has the strictfp modifier.
Within an FP-strict expression, all intermediate values must be elements of the float value set or the double value set, 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. Within an expression that is not FP-strict, some leeway is granted for an implementation to use an extended exponent range to represent intermediate results; the net effect, roughly speaking, is that a calculation might produce "the correct answer" in situations where exclusive use of the float value set or double value set might result in overflow or underflow.


When id doubt, refer to the JLS.
 
sun_guoqiao
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
It seemed the clause:

int strictfp = 10;

will not compile wherever we put in the programme.

Originally posted by Khurram Fakhar:
hey , where are u writing this declaration ?
i mean which part of the body ............

regards


 
Thomas Paul
mister krabs
Posts: 13974
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by sun_guoqiao:
It seemed the clause:
[b]
int strictfp = 10;

will not compile wherever we put in the programme.
[/B]


That's because it is a Java reserved word and can't be used as an identifier. it can only be used as a modifier for classes and methods.
 
straws are for suckers. tiny ads are for attractive people.
the value of filler advertising in 2021
https://coderanch.com/t/730886/filler-advertising
reply
    Bookmark Topic Watch Topic
  • New Topic