in src/couch_quickjs/quickjs/dtoa.c [754:842]
void build_tables(void)
{
int r, j, radix, n, col, i;
/* radix_base_table */
for(radix = 2; radix <= 36; radix++) {
r = 1;
for(j = 0; j < digits_per_limb_table[radix - 2]; j++) {
r *= radix;
}
printf(" 0x%08x,", r);
if ((radix % 4) == 1)
printf("\n");
}
printf("\n");
/* dtoa_max_digits_table */
for(radix = 2; radix <= 36; radix++) {
/* Note: over estimated when the radix is a power of two */
printf(" %d,", 1 + (int)ceil(53.0 / log2(radix)));
}
printf("\n");
/* atod_max_digits_table */
for(radix = 2; radix <= 36; radix++) {
if ((radix & (radix - 1)) == 0) {
/* 64 bits is more than enough */
n = (int)floor(64.0 / log2(radix));
} else {
n = (int)floor(128.0 / log2(radix));
}
printf(" %d,", n);
}
printf("\n");
printf("static const int16_t max_exponent[JS_RADIX_MAX - 1] = {\n");
col = 0;
for(radix = 2; radix <= 36; radix++) {
printf("%5d, ", (int)ceil(1024 / log2(radix)));
if (++col == 8) {
col = 0;
printf("\n");
}
}
printf("\n};\n\n");
printf("static const int16_t min_exponent[JS_RADIX_MAX - 1] = {\n");
col = 0;
for(radix = 2; radix <= 36; radix++) {
printf("%5d, ", (int)floor(-1075 / log2(radix)));
if (++col == 8) {
col = 0;
printf("\n");
}
}
printf("\n};\n\n");
printf("static const uint32_t pow5_table[16] = {\n");
col = 0;
for(i = 2; i <= 17; i++) {
r = 1;
for(j = 0; j < i; j++) {
r *= 5;
}
printf("0x%08x, ", r);
if (++col == 4) {
col = 0;
printf("\n");
}
}
printf("\n};\n\n");
/* high part */
printf("static const uint8_t pow5h_table[4] = {\n");
col = 0;
for(i = 14; i <= 17; i++) {
uint64_t r1;
r1 = 1;
for(j = 0; j < i; j++) {
r1 *= 5;
}
printf("0x%08x, ", (uint32_t)(r1 >> 32));
if (++col == 4) {
col = 0;
printf("\n");
}
}
printf("\n};\n\n");
}