Java Math.ulp(float f)
Syntax
Math.ulp(float f) has the following syntax.
public static float ulp(float f)
Example
In the following code shows how to use Math.ulp(float f) method.
//from w ww . j a v a 2s .c o m
public class Main {
public static void main(String[] args) {
// get two double float numbers
float x = 123.456f;
float y = 123.1f;
// print the ulp of these floats
System.out.println("Math.ulp(" + x + ")=" + Math.ulp(x));
System.out.println("Math.ulp(" + y + ")=" + Math.ulp(y));
}
}
The code above generates the following result.