BigDecimal.ulp() has the following syntax.
public BigDecimal ulp()
In the following code shows how to use BigDecimal.ulp() method.
import java.math.BigDecimal; //w ww. ja v a 2 s . c om 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.