Craig Small <[email protected]> writes:
> Can you apply this patch to your setup and see if it checks? You really
> only need to compile lib/test_strod_nol and run it.
With that patch, it succeeds on 123 but then proceeds to fail on 12.34
in my i386 chroot. However, it succeeds fully if I add 0.5 before
casting to obtain rounding rather than truncation.
--
Aaron M. Ucko, KB1CJC (amu at alum.mit.edu, ucko at debian.org)
http://www.mit.edu/~amu/ | http://stuff.mit.edu/cgi/finger/[email protected]
diff --git a/lib/test_strtod_nol.c b/lib/test_strtod_nol.c
index 0be798c..43265ea 100644
--- a/lib/test_strtod_nol.c
+++ b/lib/test_strtod_nol.c
@@ -33,8 +33,8 @@ int main(int argc, char *argv[])
double val;
for(i=0; tests[i].string != NULL; i++) {
- if(strtod_nol_or_err(tests[i].string, "Cannot parse number") !=
- tests[i].result) {
+ if((int)(strtod_nol_or_err(tests[i].string, "Cannot parse number")*100+0.5) !=
+ (int)(tests[i].result * 100 + 0.5)) {
fprintf(stderr, "FAIL: strtod_nol_or_err(\"%s\") != %f\n",
tests[i].string, tests[i].result);
return EXIT_FAILURE;