-
What is the output of below code snippet?
double d = 0.02;
double e = 0.03;
double f = e - d;
System.out.println(c);
BigDecimal _d = new BigDecimal("0.02");
BigDecimal _e = new BigDecimal("0.03");
BigDecimal _f = b.subtract(_d);
System.out.println(_f);
-
- 0.01
0.009999999999999998 - 0.01
0.01 - 0.009999999999999998
0.009999999999999998 - 0.009999999999999998
0.01 - None of these
- 0.01
Correct Option: D
BigDecimal provides more precision as compared to double. Double is faster in terms of performance as compared to BigDecimal.