You should keep in mind that the types float and double handle floating point numbers: this means that they must allocate their 32 or 64 bits between the integer and the decimal part.
And so: most digits in the integer part, most bits will be devoted to them, and the less bits - the decimal part. Thus, the decimal part will be less accurate.
The problem you suffer comes from two facts:
- Too many digits in the integer part.
- Using float.
If you need additional refueling (in accordance with the scale of values ββthat your program should handle), you should switch to double . And if you want endless precession, BigDecimal .
source share