From 7a059149ecdef5c1fc044faa4b151311cf0be9e9 Mon Sep 17 00:00:00 2001 From: cbmarini Date: Tue, 15 Jul 2025 11:31:09 +0200 Subject: [PATCH] fix: this resolves #695. --- check/fixes.frm | 33 +++++++++++++++++++++++++++++++++ sources/sort.c | 10 +++++----- 2 files changed, 38 insertions(+), 5 deletions(-) diff --git a/check/fixes.frm b/check/fixes.frm index 744c236c..edee8e4c 100644 --- a/check/fixes.frm +++ b/check/fixes.frm @@ -3914,6 +3914,39 @@ Print; assert succeeded? assert result("F") =~ expr("0") *--#] Issue642 : +*--#[ Issue695_1 : +#StartFloat 20 +CFunction f; +Local F1 = f(1.0)+f(1.0); +Local F2 = f(1.0)/3+f(1.0)*2.0; +Local F3 = 1.0*f(1.0)/3+f(1.0)*2.0; +Local F4 = f(1.0)+f(1.1); +Local F5 = f(0.5)+f(1/2); +Print; +.end +#pend_if wordsize == 2 +assert succeeded? +assert result("F1") =~ expr("2*f(1.0e+00)") +assert result("F2") =~ expr("2.33333e+00*f(1.0e+00)") +assert result("F3") =~ expr("2.33333e+00*f(1.0e+00)") +assert result("F4") =~ expr("f(1.0e+00) + f(1.1e+00)") +assert result("F5") =~ expr("f(1/2) + f(5.0e-01)") +*--#] Issue695_1 : +*--#[ Issue695_2 : +#StartFloat 30 +Symbol a,b; +CFunction f; +Local F = 1.0*f(a); +.sort +#endfloat + +Local F = F + f(a); +Print; +.end +#pend_if wordsize == 2 +assert succeeded? +assert result("F") =~ expr("f(a) + f(a)*float_(2,3,1,340282366920938463463374607431768211456)") +*--#] Issue695_2 : *--#[ PullReq535 : * This test requires more than the specified 50K workspace. #:maxtermsize 200 diff --git a/sources/sort.c b/sources/sort.c index 9b58010f..1bead149 100644 --- a/sources/sort.c +++ b/sources/sort.c @@ -2967,7 +2967,7 @@ WORD Compare1(PHEAD WORD *term1, WORD *term2, WORD level) } } #ifdef WITHFLOAT - if ( c1 == FLOATFUN && t1 == stopper1 && t2 == stopper2 && AT.aux_ != 0 ) { + if ( level == 0 && c1 == FLOATFUN && t1 == stopper1 && t2 == stopper2 && AT.aux_ != 0 ) { /* We have two FLOATFUN's. Test whether they are 'legal' */ @@ -3039,12 +3039,12 @@ WORD Compare1(PHEAD WORD *term1, WORD *term2, WORD level) } } #ifdef WITHFLOAT - if ( t1 < stopper1 && *t1 == FLOATFUN && t1+t1[1] == stopper1 - && TestFloat(t1) ) { + if ( level == 0 && t1 < stopper1 && *t1 == FLOATFUN && t1+t1[1] == stopper1 + && TestFloat(t1) && AT.aux_ != 0 ) { AT.SortFloatMode = 1; return(0); } - else if ( t2 < stopper2 && *t2 == FLOATFUN && t2+t2[1] == stopper2 - && TestFloat(t2) ) { + else if ( level == 0 && t2 < stopper2 && *t2 == FLOATFUN && t2+t2[1] == stopper2 + && TestFloat(t2) && AT.aux_ != 0 ) { AT.SortFloatMode = 2; return(0); } #endif