This week's book giveaway is in the Beginning Java forum.
We're giving away four copies of Get Programming with Java (MEAP only) and have Peggy Fisher on-line!
See this thread for details.
Win a copy of Get Programming with Java (MEAP only) this week in the Beginning Java forum!
  • 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 all forums
this forum made possible by our volunteer staff, including ...
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Bear Bibeault
  • Knute Snortum
  • Liutauras Vilda
  • Tim Cooke
  • Devaka Cooray
  • Paul Clapham
Saloon Keepers:
  • Tim Moores
  • Frits Walraven
  • Ron McLeod
  • Ganesh Patekar
  • salvin francis
  • Tim Holloway
  • Carey Brown
  • Stephan van Hulst

strictfp keyword  RSS feed

Ranch Hand
Posts: 325
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
what is the use of this strictfp keyword?
Ranch Hand
Posts: 140
  • Mark post as helpful
  • send pies
  • 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.
Ranch Hand
Posts: 46
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
Please let me know, if u could find any corrections or additional information regarding the same.
regards Jacob
I want my playground back. Here, I'll give you this tiny ad for it:
RavenDB is an Open Source NoSQL Database that’s fully transactional (ACID) across your database
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!