Skip to content

Commit c6f4a40

Browse files
committed
fix: fixed the compiler warning in CoStrictRounding. Added two more tests for the StrictRounding statement to have full coverage.
1 parent f51b02a commit c6f4a40

File tree

2 files changed

+37
-5
lines changed

2 files changed

+37
-5
lines changed

check/features.frm

Lines changed: 32 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1463,7 +1463,7 @@ assert result("ATANH") =~ expr("
14631463
- 6.08698087464190136361e-01*atanh( - 5.4321e-01)
14641464
")
14651465
*--#] evaluate_atanh :
1466-
*--#[ strictrounding :
1466+
*--#[ strictrounding_1 :
14671467
#StartFloat 6d
14681468
CFunction f;
14691469
Local F1 = 1.23456789e-4+f(1.0)+f(1.0000001);
@@ -1482,7 +1482,37 @@ Print;
14821482
assert succeeded?
14831483
assert result("F1") =~ expr("1.23457e-04 + f(1.0e+00) + f(1.0e+00)")
14841484
assert result("F2") =~ expr("1.235e-04 + 2*f(1.0e+00)")
1485-
*--#] strictrounding :
1485+
*--#] strictrounding_1 :
1486+
*--#[ strictrounding_2 :
1487+
#StartFloat 20b
1488+
CFunction f;
1489+
Local F = 1.1e-4;
1490+
StrictRounding 5b;
1491+
.sort
1492+
1493+
#EndFloat
1494+
#StartFloat 40d
1495+
Print;
1496+
.end
1497+
#pend_if wordsize == 2
1498+
assert succeeded?
1499+
assert result("F") =~ expr("1.10626220703125e-04")
1500+
*--#] strictrounding_2 :
1501+
*--#[ strictrounding_error:
1502+
#-
1503+
StrictRounding;
1504+
#StartFloat 10d
1505+
StrictRounding 5;
1506+
StrictRounding d5;
1507+
StrictRounding 5 d;
1508+
.end
1509+
#pend_if wordsize == 2
1510+
runtime_error?("Illegal attempt for strict rounding without activating floating point numbers.")
1511+
runtime_error?("Forgotten #startfloat instruction?")
1512+
runtime_error?("Illegal argument(s) in StrictRounding statement: ''")
1513+
runtime_error?("Illegal argument(s) in StrictRounding statement: 'd5'")
1514+
runtime_error?("Illegal argument(s) in StrictRounding statement: ',d'")
1515+
*--#] strictrounding_error :
14861516
*--#[ chop :
14871517
#StartFloat 15d
14881518
#StartFloat 15d

sources/float.c

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1320,15 +1320,17 @@ int CoStrictRounding(UBYTE *s)
13201320
if ( *s == 0 ) {
13211321
/* No subkey, which means round to default precision */
13221322
x = AC.DefaultPrecision - AC.MaxWeight - 1;
1323-
Add4Com(TYPESTRICTROUNDING,x,2);
1324-
return(0);
1323+
base = 2;
13251324
}
1326-
if ( FG.cTable[*s] == 1 ) { /* number */
1325+
else if ( FG.cTable[*s] == 1 ) { /* number */
13271326
ParseNumber(x,s)
13281327
if ( tolower(*s) == 'd' ) { base = 10; s++; } /* decimal base */
13291328
else if ( tolower(*s) == 'b' ){ base = 2; s++; } /* binary base */
13301329
else goto IllPar; /* invalid base specification */
13311330
}
1331+
else {
1332+
goto IllPar;
1333+
}
13321334
while ( *s == ' ' || *s == ',' || *s == '\t' ) s++;
13331335

13341336
/* Check for invalid arguments */

0 commit comments

Comments
 (0)