BigDecimal toEngineeringString not working

I would to use toEngineeringString() but it doesn't works :

Log.v("smslms",BigDecimal.valueOf(1_000_0000_000_000_000L).toEngineeringString());`

output :

09-11 16:26:12.221  18492-18492/skarwild.game V/smslmsīš• 10000000000000000
Jon Skeet
people
quotationmark

It's behaving exactly as documented:

Returns a string that represents the BigDecimal as described in the toString() method, except that if exponential notation is used, the power of ten is adjusted to be a multiple of three (engineering notation) such that the integer part of nonzero values will be in the range 1 through 999.

Now toString() specifies:

A standard canonical string form of the BigDecimal is created as though by the following steps: first, the absolute value of the unscaled value of the BigDecimal is converted to a string in base ten using the characters '0' through '9' with no leading zeros (except if its value is zero, in which case a single '0' character is used).

Next, an adjusted exponent is calculated; this is the negated scale, plus the number of characters in the converted unscaled value, less one. That is, -scale+(ulength-1), where ulength is the length of the absolute value of the unscaled value in decimal digits (its precision).

If the scale is greater than or equal to zero and the adjusted exponent is greater than or equal to -6, the number will be converted to a character form without using exponential notation.

In our case the scale is 0, so the adjusted exponent is 16 (or something thereabouts). Therefore the value is converted to a character form without using exponential notation.

people

See more on this question at Stackoverflow