• 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

FP Strict ??

 
Ranch Hand
Posts: 5399
1
Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi there
I was going through JLS Value set conversion.
and after that I am slightly confused.
if an expression is FP-strict then expression will never evaluates in Flaot.POSITIVE_INFINITY or Double.POSITIVE_INFINITY ??
what does it mean by overflow/underflow in float. If a positive float number is added with a number which exceeds max limit of result then result will be negative in case of FP-strict expression ??
can anyone plz more elaborate abt Value set conversion.
TIA
------------------
Regards
Ravish
 
Ranch Hand
Posts: 2120
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Ravish


if an expression is FP-strict then expression will never evaluates in Flaot.POSITIVE_INFINITY or Double.POSITIVE_INFINITY ??


No, it is not like that read below

from JLS 4.3

Every implementation of the Java programming language is required to support two standard sets of floating-point values, called the float value set and the double value set . In addition, an implementation of the Java programming language may support either or both of two extended-exponent floating-point value sets, called the float-extended-exponent value set and the double-extended-exponent value set . These extended-exponent value sets may, under certain circumstances, be used instead of the standard value sets to represent the values of expressions of type float or double (�5.1.8, �15.4).


The number of bits for the exponents in the float and double value set are 8 and 11. While 11 and more, and 15 and more, are for the "extended" value set fot float and double respectively.

Overflow ocurrs is a number is greater than the value set. Float/Double.POSITIVE/NEGATIVE_INFINITY represents any values that are too big for a value set.
Underflow ocurrs is a number is two small for being represented in a value set. Zero or a denormalized number represent them.

from JLS 15.4


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.


An expression is FP-strict if ocurrs wihtin a class, interface, or method that holds the strictfp modifier, or it is a constant expresion as defined in JLS 15.28
The advantage of non FP-strict expressions is performance: they could utilize some floating point arithmethic available in moderm microprocessors.
 
R K Singh
Ranch Hand
Posts: 5399
1
Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Thanks Jose !!
------------------
Regards
Ravish
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic