Qbasicnews.com
July 04, 2020, 09:39:13 AM *
Welcome, Guest. Please login or register.

Login with username, password and session length
News: Back to Qbasicnews.com | QB Online Help | FAQ | Chat | All Basic Code | QB Knowledge Base
 
   Home   Help Search Login Register  
Pages: [1]
  Print  
Author Topic: Bug in SGN function  (Read 1930 times)
jdebord
Member
*
Posts: 60


WWW
« on: February 15, 2005, 09:59:45 AM »

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.
Logged

ean Debord
----------------
Math library for FreeBasic:
http://www.unilim.fr/pages_perso/jean.debord/tpmath/fbmath.zip
Sterling Christensen
Na_th_an
*****
Posts: 1328


« Reply #1 on: February 15, 2005, 10:06:42 AM »

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;
}
Logged
v3cz0r
I hold this place together
*****
Posts: 924



WWW
« Reply #2 on: February 15, 2005, 12:28:33 PM »

Right, fixed, problem was at the AST module, converting the src node to interger for some stupid mistake.
Logged

Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.21 | SMF © 2015, Simple Machines Valid XHTML 1.0! Valid CSS!