Current location - Plastic Surgery and Aesthetics Network - Plastic surgery and beauty - The result of multiplying 2.3 by 100 in Java and Javascript has an error of 0.0000000000003. I don't know how you solved it when you were doing the project.
The result of multiplying 2.3 by 100 in Java and Javascript has an error of 0.0000000000003. I don't know how you solved it when you were doing the project.
Two schemes:

1. Integer * 10 (or 100, 1000 ...) is converted into plastic multiplication (addition, subtraction, division, etc.) and then divided by 10 (or 100, ...

2.java converts numbers into BigDecimal, and then calls the addition, subtraction, multiplication and division provided in BigDecimal.