GLBasic User Manual

Main sections

SGN()


s#% = SGN(n#%)



Returns the sign of a number:
n>0 -> 1
n=0 -> 0
n<0 -> -1

Example
n1=5
n2=-350
n3=0
PRINT "SGN of "+n1+" is "+SGN(n1), 0, 0
PRINT "SGN of "+n2+" is "+SGN(n2), 0, 10
PRINT "SGN of "+n3+" is "+SGN(n3), 0, 20
DRAWSPRITE 0, 100, 100
SHOWSCREEN
MOUSEWAIT


Output:
SGN of 5 is 1
SNG of -350 is -1
SNG of 0 is 0

See also...