Skip to content

Commit ae8d89f

Browse files
committed
oops, abs() != fabs() - and DBL_EPSILON isn't what I thought it was
1 parent 19df57a commit ae8d89f

3 files changed

Lines changed: 198 additions & 194 deletions

File tree

src/express/expparse.y

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1587,13 +1587,15 @@ literal(A) ::= TOK_INTEGER_LITERAL(B).
15871587
}
15881588
literal(A) ::= TOK_REAL_LITERAL(B).
15891589
{
1590-
if( ( abs( B.rVal ) <= FLT_EPSILON ) && ( abs( B.rVal ) > 0 ) ) {
1590+
/* if rVal (a double) is nonzero and <= the smallest positive float, print a warning */
1591+
if( ( fabs( B.rVal ) <= nextafterf( 0.0, 1.0 ) )
1592+
&& ( fabs( B.rVal ) > 0 ) ) {
15911593
Symbol sym;
15921594
sym.line = yylineno;
15931595
sym.filename = current_filename;
15941596
ERRORreport_with_symbol(ERROR_warn_small_real, &sym, B.rVal );
15951597
}
1596-
if( abs( B.rVal ) < DBL_EPSILON ) {
1598+
if( fabs( B.rVal ) < nextafter( 0.0, 1.0 ) ) {
15971599
A = LITERAL_ZERO;
15981600
} else {
15991601
A = EXPcreate_simple(Type_Real);

0 commit comments

Comments
 (0)