Thank you! The simplicity is mostly thanks to Schubfach although I did simplify it a bit more. Unfortunately the paper makes it appear somewhat complex because of all the talk about generic bases and Java workarounds.
C++ also provides countl_zero: https://en.cppreference.com/w/cpp/numeric/countl_zero.html. We currently use our own for maximum portability.
I considered computing the table at compile time (you can do it in C++ using constexpr) but decided against it not to add compile-time overhead, however small. The table never changes so I'd rather not make users pay for recomputing it every time.
I have been doing some tests. Is it correct to assume that it converts 1.0 to "0.000000000000001e+15".
Is there a test suite it is passing?
#include "zmij.h"
#include <stdio.h>
int main() {
char buf[zmij::buffer_size];
zmij::dtoa(1.0, buf);
puts(buf);
}
I get `g++ zmij.cc test.c -o test && ./test` => `0.000000000000001e+15`That is what Schubfach does