In Java, when a double or bigdecimal decimal is converted to a string, it is often expressed in scientific notation, and we generally do not want to use scientific notation, which can be done by:
DecimalFormat a = new DecimalFormat ( "#,# #0.00000000");
system.out.println (A.format (11111111.0000001000000001)); The
way to format the output string.
for BigDecimal decimals, the ToString function can be used with confidence if the precision <=6 is established. However, for >6 precision, it is possible to use scientific notation, the viewer code is judged as follows:
Long adjusted =-(long) scale + (coeff.length-1);
if ((scale >= 0) && (adjusted >=-6)) {
& nbsp; the ToString of non-scientific counting method .
}
where scale refers to the precision of BigDecimal,
Coeff corresponds to the ToString string that uses BigInteger stored values, Coeff = Intval.abs (). ToString (). ToCharArray (), That is, BigDecimal the integer value under the corresponding precision, such as BigDecimal OB = new BigDecimal (0.00000011), the accuracy of OB is 7, then coeff= "1"; if Ob=new BigDecimal ( 0.10000011), then coeff= "1000001", if Ob=new BigDecimal (0.00000001), then coeff= "0";
Use more BigDecimal less double
How to make a double type in Java not represented by scientific notation