Bitwise operations: Difference between revisions
m
→{{header|FutureBasic}}
No edit summary |
|||
Line 3,270:
=={{header|FutureBasic}}==
FB does not have a bitwise symbol for not, but rather uses the "not" expression. It does not support predefined bitwise symbols for rotate left and rotate right, but functions in this demo provide that capability.
<lang futurebasic>window 1, @"Bitwise Operations", (0,0,650,270)
▲end fn = ( ( 2^n * b) mod 256) or (b > 127)
▲end fn = (b >> n mod 32) or ( b << (32-n) mod 32)
local fn bitwise( a as long, b as long )
print @"Input: a = "; a; @" b = "; b
print
print @"AND :", @"a && b = ", bin
print @"NAND :", @"a ^& b = ", bin
print @"OR :", @"a || b = ", bin
print @"NOR :", @"a ^| b = ", bin
print @"XOR :", @"a ^^ b = ", bin
print @"NOT :", @" not a = ", bin
print
print @"Left shift :", @"a << b =", bin
print @"Right shift :", @"a >> b =", bin
print
print @"Rotate left :", @"fn rotl( a, b ) = ", bin
print @"Rotate right :", @"fn rotr( a, b ) = ", bin
end fn
fn bitwise( 255, 2 )
HandleEvents</lang>
Output:
|