2 * Handling of the int64 and uint64 types. Done in 32-bit integers,
3 * for (pre-C99) portability. Hopefully once C99 becomes widespread
4 * we can kiss this lot goodbye...
12 uint64 uint64_div10(uint64 x, int *remainder)
20 * Now we have to add in the remainder left over from x.hi.
23 y.lo += r2 * 2 * (0x80000000 / 10);
24 rem += r2 * 2 * (0x80000000 % 10);
33 void uint64_decimal(uint64 x, char *buffer)
40 x = uint64_div10(x, &d);
42 buf[--start] = d + '0';
43 } while (x.hi || x.lo);
45 memcpy(buffer, buf + start, sizeof(buf) - start);
46 buffer[sizeof(buf) - start] = '\0';
49 uint64 uint64_make(unsigned long hi, unsigned long lo)
57 uint64 uint64_add(uint64 x, uint64 y)
60 x.hi += y.hi + (x.lo < y.lo ? 1 : 0);
64 uint64 uint64_add32(uint64 x, unsigned long y)
69 return uint64_add(x, yy);
72 int uint64_compare(uint64 x, uint64 y)
75 return x.hi < y.hi ? -1 : +1;
77 return x.lo < y.lo ? -1 : +1;