Skip to content

Commit ad194da

Browse files
authored
Merge pull request #192 from Joe7M/master
Bugfixes for LINEQN and floating-point string conversion
2 parents 4aacf4b + 1128c5f commit ad194da

File tree

4 files changed

+4
-2
lines changed

4 files changed

+4
-2
lines changed

samples/distro-examples/tests/all.bas

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -245,3 +245,4 @@ print "VAL:" + VAL (s)
245245
print "WEEKDAY:" + WEEKDAY(dmy) + " " + WEEKDAY(1,1,2020) + " " + WEEKDAY(JULIAN(d,m,y))
246246
print "XPOS:" + XPOS
247247
print "YPOS:" + YPOS
248+
print "RoundPrecisionBug:"; 32.99999999999999

samples/distro-examples/tests/output/all.out

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -228,3 +228,4 @@ VAL:0
228228
WEEKDAY:-1 3 1
229229
XPOS:0
230230
YPOS:0
231+
RoundPrecisionBug:33

src/common/blib_math.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ void mat_gauss_jordan(var_num_t *a, var_num_t *b, int n, double toler) {
121121
indxr[i] = irow;
122122
indxc[i] = icol;
123123

124-
if (a[icol * n + icol] < toler) {
124+
if (fabs(a[icol * n + icol]) < toler) {
125125
err_matsig();
126126
free(indxc);
127127
free(indxr);

src/common/fmt.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,7 @@ void bestfta_p(var_num_t x, char *dest, var_num_t minx, var_num_t maxx) {
183183
}
184184
fpart = fround(frac(x), precision) * pow(10, precision);
185185

186-
if (fpart >= FMT_xRND) { // rounding bug
186+
if (fpart >= pow(10, precision)) { // rounding bug, i.e: print 32.99999999999999 -> Output: 32.1
187187
ipart = ipart + 1.0;
188188
if (ipart >= maxx) {
189189
ipart = ipart / 10.0;

0 commit comments

Comments
 (0)