package com.nagaraju.explore;
import java.math.BigDecimal;
public class BigDecimalExplore {
public static void main(String[] args) {
double a = 0.02;
double b = 0.03;
double c = b - a;
System.out.println("Double:-"+c);
BigDecimal _a = new BigDecimal("0.02");
BigDecimal _b = new BigDecimal("0.03");
BigDecimal _c = _b.subtract(_a);
System.out.println("BigDecimal:-"+_c);
}
}
<[> When we Observe the result, we came to know that BigDecimal is giving the exact value.
No comments:
Post a Comment