errol3: Wrong result for 9.007199254740992e15
scurest opened this issue · comments
Reproduce with
$ cat a.c
#include "errol.h"
#include <stdio.h>
int main() {
double x = 9.007199254740992e15;
char buf[100] = {0};
int exp = errol3_dtoa(x, buf);
printf("buf: %s\nexp: %d\n", buf, exp);
return 0;
}
$ g++ a.c liberrol.a && ./a.out
buf:
exp: 37
Moreover, this also causes an OOB access at this line
Line 628 in d31842f
You can test this by compiling with -fsanitize=address
.
9.007199254740992e15 is the smallest number that gets passed on to errol_int
Lines 390 to 391 in d31842f
If the >= is changed to a >, it seem to work.