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.





















Home »
  Java Tutorial »
    java.lang »




Boolean
Byte
Character
Class
Double
Enum
Float
Integer
Long
Math
Number
Object
Package
Process
ProcessBuilder
Runnable
Runtime
SecurityManager
Short
StackTraceElement
StrictMath
String
StringBuffer
StringBuilder
System
Thread
ThreadGroup
ThreadLocal
Throwable