Public static void main (String [] args) {
//# # # # # # # # # # # BigDecimal usage
//addition: add
//subtraction: subtract
//method: multiply
//division: divide
BigDecimal num=new BigDecimal (" 0.00 ");//will always keep two decimal places
BigDecimal num1=new BigDecimal (0);
//BigDecimal num2=new BigDecimal (" null ");//error
//BigDecimal num4=new BigDecimal (" ");//error
BigDecimal num90=num. Add (new BigDecimal (4.22));//there will be a super small digital 4.21999999999999975131004248396493494510650634765625
BigDecimal num91=num. Add (new BigDecimal (" 4.22 "));//0 + 4=4.22
BigDecimal num92=num1. Add (new BigDecimal (4.22));//there will be a super small digital
BigDecimal num93=num1. Add (new BigDecimal (" 4.22 "));//0 + 4=4.22
BigDecimal num94=new BigDecimal (4.22);//50 decimal places
BigDecimal num95=num1. Add (new BigDecimal (" 4.22 "));//4.22
Conclusions compareTo comparison//in front of big=1, behind the big=equal - 1=0
If (num95.com pareTo (num91)==0)//- 1==0
If (num91.com pareTo (num95)==0)//1==0
If (num91.com pareTo (num90)==0)//1==0
If (num94.com pareTo (BigDecimal. ZERO)==0)//- 1==0
If (num95.com pareTo (BigDecimal. ZERO)==0)//- 1==0
If (num91.com pareTo (BigDecimal. ZERO)==0)//1==0
If (num90.com pareTo (BigDecimal. ZERO)==0)//1==0
If (num1.com pareTo (BigDecimal. ZERO)==0.00)//true
If (num1.com pareTo (BigDecimal. ZERO)==0)//true
If (num.com pareTo (BigDecimal. ZERO)==0.00)//true
If (num.com pareTo (BigDecimal. ZERO)==0) {//true
System. The out. Print (" is equal to 0 ");
} else {
System. The out. Print (" is not equal to 0 ");
}
}