public static int writeDouble(char[] buf, int off, double doubleValue, boolean json) {
        long bits;
        if (doubleValue == 0) {
            bits = Double.doubleToLongBits(doubleValue);
            if (bits == 0x8000000000000000L) {
                buf[off++] = '-';
            }
            buf[off] = '0';
            IOUtils.putIntUnaligned(buf, off + 1, DOT_ZERO_32);
            return off + 3;
        }
        boolean sign = doubleValue < 0;
        if (sign) {
            if (!json || doubleValue != Double.NEGATIVE_INFINITY) {
                buf[off++] = '-';
            }
            doubleValue = -doubleValue;
        }

        if (doubleValue == (long) doubleValue) {
            long output = (long) doubleValue;
            int numLength = stringSize(output);
            return writeDecimal(output, numLength, numLength - 1, buf, off);
        }

        Scientific scientific = NumberUtils.doubleToScientific(doubleValue);
        int e10 = scientific.e10;
        if (!scientific.b) {
            return writeDecimal(scientific.output, scientific.count, e10, buf, off);
        }
        if (scientific == Scientific.SCIENTIFIC_NULL) {
            if (json) {
                IOUtils.putLongUnaligned(buf, off, NULL_64);
                return off + 4;
            } else {
                if (doubleValue == Double.POSITIVE_INFINITY) {
                    IOUtils.putLongUnaligned(buf, off, INFI);
                    IOUtils.putLongUnaligned(buf, off + 4, NITY);
                    return off + 8;
                } else {
                    buf[off] = 'N';
                    buf[off + 1] = 'a';
                    buf[off + 2] = 'N';
                    return off + 3;
                }
            }
        }
        if (e10 >= 0) {
            char[] chars = POSITIVE_DECIMAL_POWER_CHARS[e10];
            System.arraycopy(chars, 0, buf, off, chars.length);
            return off + chars.length;
        } else {
            char[] chars = NEGATIVE_DECIMAL_POWER_CHARS[-e10];
            System.arraycopy(chars, 0, buf, off, chars.length);
            return off + chars.length;
        }
    }
Conversion of ieee floating point numbers to Scientific notation

<p> Using the difference estimation method </p>
<p> The output may not be the shortest, but the general result is correct </p>

@param doubleValue &gt; 0
core/src/main/java/com/alibaba/fastjson2/util/NumberUtils.java