in gflog-core/src/main/java/com/epam/deltix/gflog/core/util/Formatting.java [1429:1460]
public static int formatDouble(@Nonnegative double value,
final @Nonnegative int precision,
final @Nonnull MutableBuffer buffer,
@Nonnegative int offset) {
// Preconditions:
// assert !Double.isNaN(value) && Long.MIN_VALUE < value && value <= Long.MAX_VALUE;
// assert precision >= 0 && precision <= 9
// assert buffer != 0;
// assert offset >= 0;
if (value < 0) {
value = -value;
buffer.putByte(offset++, MINUS);
}
final int multiplier = multiplierOfUInt(precision);
long integer = (long) value;
int fraction = (int) Math.round((value - integer) * multiplier);
if (fraction >= multiplier) {
integer++;
fraction -= multiplier;
}
offset = formatULong(integer, buffer, offset);
if (fraction > 0) {
offset = formatFraction(fraction, precision, buffer, offset);
}
return offset;
}