Java BigDecimal without E

bigdecimal, java

Solution

To get a `String` representation of the `BigDecimal` without the exponent part, you can use `BigDecimal.toPlainString()`. In your example:

BigDecimal x = new BigDecimal("5521.0000000001");
x = x.add(new BigDecimal("-1").
              multiply(x.divideToIntegralValue(new BigDecimal("1.0"))));
System.out.println(x.toPlainString());

prints

0.0000000001

Problem

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.

Original source