Sometimes, it may even output shorter strings, so it’s not about “short” or “long” ! That’s an interesting element that came out in this discussion. Thanks to @asynth
–
Maybe something like this wouldn’t intrude on the rest of the code too much?
static void prettyFormatFloat(char* str, double d, bool useRyu = false)
{
if (useRyu) {
d2s_buffered(d, str);
} else {
sprintf(str, "%.14g", d);
}
// rest of the function
}
prettyFormatFloat(buffer, 1.234);
prettyFormatFloat(buffer, 1.234, true);
// or maybe this, leaving default always to false
prettyFormatFloat(str, slotRawFloat(slot), useRyu);
EDIT: Additionally, changes to the documentation on how this format allows you to return to the exact binary representation of the floating-point number are also significant.