The variable BigDecimal bet = new BigDecimal(0.00000010) and transferred to the server and it returns a value other than expected. It is not clear why.
|
1 answer
When using a constructor that accepts a double as an input, an unpleasant feature noted in the documentation arises.
Since a real number during binary translation is usually represented by an infinite binary fraction, when creating an object, for example,
BigDecimal(0.1), the mantissa stored in the object will be very large. ( link to article )
Therefore, the number will not be saved accurately. In this regard, it is better to use a constructor that accepts a line as input:
Bigdecimal bet = new Bigdecimal("0.00000010"); |