• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

strictfp keyword

 
Ranch Hand
Posts: 325
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
what is the use of this strictfp keyword?
thanks
 
Ranch Hand
Posts: 140
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
It is used to control floating point behaviour.
By default, java will allow the processor to do any floating point math to the best of its ability (if it can use 128bit numbers for example it will) and then trim off any excess data from the right hand side (loss of precision).
This means that for different hardware, the rounding errors may not be the same if the length of internal floating point numbers are different.
strictfp constrains all the intermediate fp number to be of java length.
So, strictfp requires all fp math to be equivalent accross VMs, but it does hit performance.
James
 
Ranch Hand
Posts: 46
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
strictfp simply means perform strict floating point calculations on the expression. I will try to explain what I understood from the defenitions.
Older jvm (Classic [interpreter]) used original virtual machine specification which calculated all the floating point operations strictly. ie if (a*b)/(c*d) where all or any are floating point numbers, the intermediate results obtained should also be withing the range of Float. ie The above expression will receive the expected result only if a*b<Float.MAX_VALUE and c*d<Float.MAX_VALUE.(Classic Jvm). Rather than truncated at the end, the intermediate results also gets truncated.
But in new Jvm (Hotspot VM), things are a little different. All the floating point operations are performed without intermediate bounds checking; only the final answer is truncated to fit within Float.MAX_VALUE.
By adding strictfp as class/method modifier, we may change the default behaviour(of new VMs) of floating point operations, to that of the old ones (like in Classic JVM interpreters).
This link could help u get more details.
http://www.javaworld.com/javaworld/jw-12-1998/jw-jbe-jvm.html
Please let me know, if u could find any corrections or additional information regarding the same.
regards Jacob
 
reply
    Bookmark Topic Watch Topic
  • New Topic