Sep 28, 2000 #1 brassy Technical User Sep 28, 2000 1 IN How do you shift bits left or right in Qbasic [sig][/sig]
Oct 1, 2000 #2 Guest_imported New member Jan 1, 1970 0 DEFINT A-Z x = 8 y = shr(x,3) if y<>1 then print "shr failed" z = shl(x,2) if z<>32 then print "shl failed" END 'shifting bits left function shl%(x%,howmuch%) if howmuch%<0 then beep:end shl% = x% * (2^howmuch%) end function 'shifting bits to the right function shr%(x%,howmuch%) if howmuch%<0 then beep:end shr% = x% \ (2^howmuch%) end function Upvote 0 Downvote
DEFINT A-Z x = 8 y = shr(x,3) if y<>1 then print "shr failed" z = shl(x,2) if z<>32 then print "shl failed" END 'shifting bits left function shl%(x%,howmuch%) if howmuch%<0 then beep:end shl% = x% * (2^howmuch%) end function 'shifting bits to the right function shr%(x%,howmuch%) if howmuch%<0 then beep:end shr% = x% \ (2^howmuch%) end function