PDA

View Full Version : Math with Bits



ErosOlmi
18-03-2007, 11:32
uses "console"

dim a,b,c as long

b = &H09700
c = &H03FFF

a = b and c
PrintResults("--- AND operation: a = b and c", a, b, c)

a = b or c
PrintResults("--- OR operation: a = b or c", a, b, c)

a = not b
PrintResults("--- NOT operation: a = not b ", a, b, c)
console_waitkey

function PrintResults(Operation as string, a as long, b as long, c as long)
console_writeline Operation
console_writeline "b = " & BIN$(b, 32) & " " & hex$(b, 4)
console_writeline "c = " & BIN$(c, 32) & " " & hex$(c, 4)
console_writeline string$(40, "-")
console_writeline "a = " & BIN$(a, 32) & " " & hex$(a, 4)
console_writeline ""
end function

kryton9
18-03-2007, 22:41
Thanks Eros nice example!!