Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Bit manipulation

Status
Not open for further replies.

brassy

Technical User
Sep 28, 2000
1
IN
How do you shift bits left or right in Qbasic [sig][/sig]
 
DEFINT A-Z
x = 8
y = shr(x,3)
if y<>1 then print &quot;shr failed&quot;
z = shl(x,2)
if z<>32 then print &quot;shl failed&quot;
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


 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top