Main Menu

Get Sign Bit from Integer

Started by kevin, October 28, 2003, 09:00:43 PM

Previous topic - Next topic

kevin


Simple example of how to get the SIGN BIT from an Integer in www.PlayBASIC.com

PlayBASIC Code: [Select]
 a =  12345
b = -12345

; Using the getSign function is one way
; Note; This reads the sign bit of value)
print "Using GetSign function"
print GetSign(a)
print GetSign(b)
print ""

; GetSign() is basically the same as doing this
print rol32(a,1) and 1
print rol32(b,1) and 1
print ""


; The SNG() function returns the direction of SNG()
; -1 ='s nagtive, 0 = zero and 1 it's positive
print "Using SGN() function"
print Sgn(a)
print Sgn(b)
print ""

; or you can test if it's less then 0
print "Manual Tests"
print a<0
print b<0
print ""




print "done"

sync
waitkey