@NotNull @Override public ByteStringAppender append(long num) { if (num < 0) { if (num == Long.MIN_VALUE) { write(MIN_VALUE_TEXT); return this; } writeByte('-'); num = -num; } if (num == 0) { writeByte('0'); } else { appendLong0(num); } return this; }
@NotNull @Override public ByteStringAppender append(long num) { if (num < 0) { if (num == Long.MIN_VALUE) { write(MIN_VALUE_TEXT); return this; } writeByte('-'); num = -num; } if (num == 0) { writeByte('0'); } else { appendLong0(num); } return this; }
@NotNull @Override public ByteStringAppender append(double d, int precision) { if (precision < 0) precision = 0; long power10 = Maths.power10(precision); if (power10 < 0) power10 = 100000000000000000L; if (d < 0) { d = -d; writeByte('-'); } double d2 = d * power10; if (d2 > Long.MAX_VALUE || d2 < Long.MIN_VALUE + 1) return append(d); long val = (long) (d2 + 0.5); while (precision > 1 && val % 10 == 0) { val /= 10; precision--; } if (precision > 0 && val % 10 == 0) { val = (val + 5) / 10; precision--; } if (precision > 0) appendDouble0(val, precision); else appendLong0(val); return this; }
@NotNull @Override public ByteStringAppender append(double d, int precision) { if (precision < 0) precision = 0; long power10 = Maths.power10(precision); if (power10 < 0) power10 = 100000000000000000L; if (d < 0) { d = -d; writeByte('-'); } double d2 = d * power10; if (d2 > Long.MAX_VALUE || d2 < Long.MIN_VALUE + 1) return append(d); long val = (long) (d2 + 0.5); while (precision > 1 && val % 10 == 0) { val /= 10; precision--; } if (precision > 0 && val % 10 == 0) { val = (val + 5) / 10; precision--; } if (precision > 0) appendDouble0(val, precision); else appendLong0(val); return this; }
appendLong0(intValue); mantissa -= intValue << shift; if (mantissa > 0) { appendLong0(val2); for (int i = 0; i < digits; i++) writeByte('0');
appendLong0(intValue); mantissa -= intValue << shift; if (mantissa > 0) { appendLong0(val2); for (int i = 0; i < digits; i++) writeByte('0');
@NotNull @Override public ByteStringAppender appendTimeMillis(long timeInMS) { int hours = (int) (timeInMS / (60 * 60 * 1000)); if (hours > 99) { appendLong0(hours); // can have over 24 hours. } else { writeByte((char) (hours / 10 + '0')); writeByte((char) (hours % 10 + '0')); } writeByte(':'); int minutes = (int) ((timeInMS / (60 * 1000)) % 60); writeByte((char) (minutes / 10 + '0')); writeByte((char) (minutes % 10 + '0')); writeByte(':'); int seconds = (int) ((timeInMS / 1000) % 60); writeByte((char) (seconds / 10 + '0')); writeByte((char) (seconds % 10 + '0')); writeByte('.'); int millis = (int) (timeInMS % 1000); writeByte((char) (millis / 100 + '0')); writeByte((char) (millis / 10 % 10 + '0')); writeByte((char) (millis % 10 + '0')); return this; }
@NotNull @Override public ByteStringAppender appendTimeMillis(long timeInMS) { int hours = (int) (timeInMS / (60 * 60 * 1000)); if (hours > 99) { appendLong0(hours); // can have over 24 hours. } else { writeByte((char) (hours / 10 + '0')); writeByte((char) (hours % 10 + '0')); } writeByte(':'); int minutes = (int) ((timeInMS / (60 * 1000)) % 60); writeByte((char) (minutes / 10 + '0')); writeByte((char) (minutes % 10 + '0')); writeByte(':'); int seconds = (int) ((timeInMS / 1000) % 60); writeByte((char) (seconds / 10 + '0')); writeByte((char) (seconds % 10 + '0')); writeByte('.'); int millis = (int) (timeInMS % 1000); writeByte((char) (millis / 100 + '0')); writeByte((char) (millis / 10 % 10 + '0')); writeByte((char) (millis % 10 + '0')); return this; }