Home >>Java Math Methods >Java Math.ulp() method
Java Math.ulp() Method in Java Math is used to returns an ulp of the argument 's size. An ulp is the last place on the device. The positive distance between the given value and the next value which is greater in magnitude is an ulp of a float or double.
public static double ulp(double x) public static float ulp(float x)
x = This parameter is used for a floating-point value whose ulp is to be returned
It is used to returns the size of an ulp of the argument.
public class MyClass
{
public static void main(String[] args)
{
double x = 6.2;
System.out.println(Math.ulp(x));
}
}
public class MyClass
{
public static void main(String[] args)
{
float x = -2.0f / 0;
System.out.println(Math.ulp(x));
}
}