StrictMath.ulp(float): This method is available in java.lang.StrictMath class of Java.
Syntax:
float java.lang.StrictMath.ulp(float f)
This method takes one argument of type float as its parameter. This method returns the size of an ulp of the argument.
Note:
1. If the argument is NaN, then the result is NaN.
2. If the argument is positive or negative infinity, then the result is positive infinity.
3. If the argument is positive or negative zero, then the result is Float.MIN_VALUE.
4. If the argument is ±Float.MAX_VALUE, then the result is equal to 2104.
Parameters: One parameter is required for this method.
f: the floating-point value whose ulp is to be returned.
Returns: the size of an ulp of the argument.
Exceptions: NA
Approach
Java
public class StrictMathulpfloat {public static void main(String[] args) {float f = 16.7f;System.out.println(StrictMath.ulp(f));}}
Output:
1.9073486E-6
No comments:
Post a Comment