Java Tricky Program 20 - double subtraction and BigDecimal

preview_player
Показать описание
What will be result of "double d = 1.10 - 1.00", check it out in a simple java program. And why we should use BigDecimal in most of the places with arithmetic operations in Java.
Рекомендации по теме
Комментарии
Автор

Thanks for your tutorials. These are some small basics which really help when we are going forward with all the J2ee versions.

confidentraka
Автор

Thanks for the tip. Only caveat is that it requires creating multiple objects incase of BigDecimal.

anildesai
Автор

same with System.out.println(2.0-1.10) will result .890000 instead of 0.90, one of the puzzle from java puzzlers

priyanshucool