public static int formatUInt9Digits()

in gflog-core/src/main/java/com/epam/deltix/gflog/core/util/Formatting.java [1025:1059]


    public static int formatUInt9Digits(@Nonnegative int value,
                                        final @Nonnull byte[] array,
                                        final @Nonnegative int offset) {
        // Preconditions:
        // assert value >= 0 && value <= 999999999;
        // assert array != null;
        // assert offset >= 0;

        int newValue = (int) (2748779070L * (long) value >>> 38);
        int remainder = value - 100 * newValue;

        short digits = UNSAFE.getShort(ADDRESS_OF_DIGITS_TABLE + (remainder << 1));
        UNSAFE.putShort(array, ARRAY_BYTE_BASE_OFFSET + 7 + offset, digits);

        value = (int) (2748779070L * (long) newValue >>> 38);
        remainder = newValue - 100 * value;

        digits = UNSAFE.getShort(ADDRESS_OF_DIGITS_TABLE + (remainder << 1));
        UNSAFE.putShort(array, ARRAY_BYTE_BASE_OFFSET + 5 + offset, digits);

        newValue = (int) (2748779070L * (long) value >>> 38);
        remainder = value - 100 * newValue;

        digits = UNSAFE.getShort(ADDRESS_OF_DIGITS_TABLE + (remainder << 1));
        UNSAFE.putShort(array, ARRAY_BYTE_BASE_OFFSET + 3 + offset, digits);

        value = (int) (2748779070L * (long) newValue >>> 38);
        remainder = newValue - 100 * value;

        digits = UNSAFE.getShort(ADDRESS_OF_DIGITS_TABLE + (remainder << 1));
        UNSAFE.putShort(array, ARRAY_BYTE_BASE_OFFSET + 1 + offset, digits);
        UNSAFE.putByte(array, ARRAY_BYTE_BASE_OFFSET + offset, (byte) (value + ZERO));

        return offset + 9;
    }