in gflog-core/src/main/java/com/epam/deltix/gflog/core/layout/template/FastDateFormat.java [957:1005]
private static void put(final ByteBuffer buffer, int i) {
final int x = -i;
final int size = (i < 0) ? Formatting.lengthOfUInt(x) + 1 : Formatting.lengthOfUInt(i);
assert !(buffer.remaining() < size);
int q, r;
int charPos = size;
final int oldPos = buffer.position();
char sign = 0;
if (i < 0) {
sign = '-';
i = -i;
}
// Generate two digits per iteration
while (i >= 65536) {
q = i / 100;
// really: r = i - (q * 100);
r = i - ((q << 6) + (q << 5) + (q << 2));
i = q;
putAt(buffer, oldPos + (--charPos), DIGIT_ONES[r]);
putAt(buffer, oldPos + (--charPos), DIGIT_TENS[r]);
}
// Fall thru to fast mode for smaller numbers
// assert(i <= 65536, i);
do {
// 52429 = (1 << 15) + (1 << 14) + (1 << 11) + (1 << 10) + (1 << 7) + (1 << 6) + (1 << 3) + (1 << 2) + 1
// 52429 = 32768 + 16384 + 2048 + 1024 + 128 + 64 + 8 + 4 + 1
/*/
q = ((i << 15) + (i << 14) + (i << 11) + (i << 10) + (i << 7) + (i << 6) + (i << 3) + (i << 2) + i) >> (16 + 3);
/*/
q = (i * 52429) >>> (16 + 3);
//*/
r = i - ((q << 3) + (q << 1)); // r = i-(q*10) ...
putAt(buffer, oldPos + (--charPos), DIGITS[r]);
i = q;
} while (i != 0);
if (sign != 0) {
putAt(buffer, oldPos + (--charPos), sign);
}
buffer.position(oldPos + size);
}