Looking at Math class, the ulp method:
public static float ulp(float f)
If the method is applied like: Math.ulp(Float.MAX_VALUE), then this rule from the Javadoc documentation comes up:
If the argument is ±Float.MAX_VALUE, then the result is equal to 2104.
Can it be ensured from machine to machine that this number (2104) will always be that one even if the float is not strictfp?
Lack of
strictfpdoesn't magically make your numbers do weird things.It just allows platforms with more precision to execute calculations with more precision than the result actually holds (i.e. if you do calculations on
floatthen non-strictfpcode might actually use a 40-bit floating point register for intermediary steps).This doesn't change the fact that your inputs and outputs that you see in your code will still always be
float.In other words:
strictfpis not a property of afloatvariable or number. It's a property of code that operates onfloatordouble.In short: yes, if the spec says that this number will be returned, then it will be returned.