Java Data Type Tutorial - Java StrictMath.ulp(float f)








Syntax

StrictMath.ulp(float f) has the following syntax.

public static float ulp(float f)

Example

In the following code shows how to use StrictMath.ulp(float f) method.

/*from w  ww  . j a v a  2 s . c om*/

public class Main {

  public static void main(String[] args) {
  
    float f1 = 1.23f , f2 = -4.3f, f3 = 0.0f;

    System.out.println("Size of ulp of " + f1 + " : " + StrictMath.ulp(f1));
        
    System.out.println("Size of ulp of " + f2 + " : " + StrictMath.ulp(f2));
        
    System.out.println("Size of ulp of " + f3 + " : " + StrictMath.ulp(f3));
  }
}

The code above generates the following result.