Java BigDecimal.ulp()

Syntax

BigDecimal.ulp() has the following syntax.

public BigDecimal ulp()

Example

In the following code shows how to use BigDecimal.ulp() method.


import java.math.BigDecimal;
//from ww w.j  a v a2  s  .  co  m
public class Main {

   public static void main(String[] args) {

      BigDecimal bg1, bg2, bg3, bg4;

      bg1 = new BigDecimal("123");
      bg2 = new BigDecimal("1.23");

      // assign ulp value of bg1, bg2 to bg3, bg4
      bg3 = bg1.ulp();
      bg4 = bg2.ulp();

      System.out.println( "ULP value of " + bg1 + " is " + bg3 );
      System.out.println( "ULP value of " + bg2 + " is " + bg4 );
   }
}

The code above generates the following result.





















Home »
  Java Tutorial »
    java.math »




BigDecimal
BigInteger