Description Of BigDecimal: ulp()
The java.math.BigDecimal.ulp() returns the size of an ulp, a unit in the last place, of this BigDecimal . An ulp of a nonzero BigDecimal value is the positive distance between this value and the BigDecimal value next larger in magnitude with the same number of digits. An ulp of a zero value is numerically equal to 1 with the scale of this . The result is stored with the same scale as this so the result for zero and nonzero values is equal to [1, this.scale()] .BigDecimal.ulp() method returns the size of an ulp of this
Code Example Java BigDecimal
import java.math.BigDecimal; public class BigDecimalExam { public static void main(String[] args) { BigDecimal bg1 = new BigDecimal("123"); BigDecimal bg2 = new BigDecimal("1.23"); BigDecimal bg3 = bg1.ulp(); BigDecimal bg4 = bg2.ulp(); System.out.println("ULP value of " + bg1 + " is " + bg3); System.out.println("ULP value of " + bg2 + " is " + bg4); } }
ไม่มีความคิดเห็น :
แสดงความคิดเห็น