Home > Back-end >  Java BigDecimal integer times decimal data loss problem many times
Java BigDecimal integer times decimal data loss problem many times

Time:11-26

Behind only 11 before is correct, the data is not normal and was cut off, this is the original questions asked for 10 years of income, the first year of annual income is 80000, annual growth rate is 0.06.
Debugging results

Correct the results


The main code
 
BigDecimal t1=new BigDecimal (" 80000 ");//l
BigDecimal t2=new BigDecimal (" 0.06 ");
for(int i=0; i<10; I++)
{
T1=t1. The add (t2) multiply (t1));//t1 + (t2 * t1)
}
System. The out. Println (t1);
  • Related