I have a BigDecimal variable
BigDecimal x = new BigDecimal("5521.0000000001");
Formula:
x = x.add(new BigDecimal("-1")
.multiply(x.divideToIntegralValue(new BigDecimal("1.0"))));
I want to remove the integer part, to get the value x = ("0.0000000001")
, but my new value is 1E-10 and not the 0.0000000001.
toString() : Double class comes with an inbuilt method toString() method to convert a double value to string. It will not add any exponential component to the conversion.
The value of the BigDecimal is (BigInteger/10**scale). A negative scale will result in a NumberFormatException.
In scientific notation, the letter E is used to mean "10 to the power of." For example, 1.314E+1 means 1.314 * 101 which is 13.14 . Scientific notation is merely a format used for input and output. The 64-bit pattern used for a double inside the computer are the same, no matter what character format was used for input.
Try using BigDecimal.toPlainString() to get value as plain string as you require.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With