Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Bug in SGN function
#1
In FB 0.11b, The SGN function returns 1 when applied to a negative double precision number (should be -1)

Code:
dim X as double

X = -1.23#

print "X = "; X, "SGN(X) = "; SGN(X)

The single precision version does not have this bug.
ean Debord
----------------
Math library for FreeBasic:
http://www.unilim.fr/pages_perso/jean.de...fbmath.zip
Reply
#2
Confirmed. I just compiled from CVS and it exibits this bug.

EDIT: The source code for the single and double version of SGN are identical! How could they be behaving differently? Am I missing something?
Code:
/*:::::*/
FBCALL int fb_SGNSingle ( float x )
{
    if( x == 0.0 )
        return 0;
    else if( x > 0.0 )
        return 1;
    else
        return -1;
}

/*:::::*/
FBCALL int fb_SGNDouble ( double x )
{
    if( x == 0.0 )
        return 0;
    else if( x > 0.0 )
        return 1;
    else
        return -1;
}
Reply
#3
Right, fixed, problem was at the AST module, converting the src node to interger for some stupid mistake.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)