diff --git a/samples/distro-examples/tests/all.bas b/samples/distro-examples/tests/all.bas index 8af5ebe1..cd38560c 100644 --- a/samples/distro-examples/tests/all.bas +++ b/samples/distro-examples/tests/all.bas @@ -245,3 +245,4 @@ print "VAL:" + VAL (s) print "WEEKDAY:" + WEEKDAY(dmy) + " " + WEEKDAY(1,1,2020) + " " + WEEKDAY(JULIAN(d,m,y)) print "XPOS:" + XPOS print "YPOS:" + YPOS +print "RoundPrecisionBug:"; 32.99999999999999 diff --git a/samples/distro-examples/tests/output/all.out b/samples/distro-examples/tests/output/all.out index 30ed6627..35bbaa26 100644 --- a/samples/distro-examples/tests/output/all.out +++ b/samples/distro-examples/tests/output/all.out @@ -228,3 +228,4 @@ VAL:0 WEEKDAY:-1 3 1 XPOS:0 YPOS:0 +RoundPrecisionBug:33 diff --git a/src/common/blib_math.c b/src/common/blib_math.c index 5c2ba7c1..20e3089c 100644 --- a/src/common/blib_math.c +++ b/src/common/blib_math.c @@ -121,7 +121,7 @@ void mat_gauss_jordan(var_num_t *a, var_num_t *b, int n, double toler) { indxr[i] = irow; indxc[i] = icol; - if (a[icol * n + icol] < toler) { + if (fabs(a[icol * n + icol]) < toler) { err_matsig(); free(indxc); free(indxr); diff --git a/src/common/fmt.c b/src/common/fmt.c index 39125610..5131b8af 100644 --- a/src/common/fmt.c +++ b/src/common/fmt.c @@ -183,7 +183,7 @@ void bestfta_p(var_num_t x, char *dest, var_num_t minx, var_num_t maxx) { } fpart = fround(frac(x), precision) * pow(10, precision); - if (fpart >= FMT_xRND) { // rounding bug + if (fpart >= pow(10, precision)) { // rounding bug, i.e: print 32.99999999999999 -> Output: 32.1 ipart = ipart + 1.0; if (ipart >= maxx) { ipart = ipart / 10.0;