working with binary numbers with bitwise operators

Alejandro Tejada capellan2000 at yahoo.com
Sun May 30 01:33:29 EDT 2004


Hi Developers,

I've been working with bitwise operators in 
binary numbers of 48 bits like this:
"010011001100001110101010101101100101110111010101"
and noticed the following:

If i convert this 48 bit binary number in decimal 
then i get a negative number:

put baseconvert
(010011001100001110101010101101100101110111010101,2,10)

results in
-2864078293

and i've noticed that the function "bitnot" produces 
this result:

put bitnot 35 produces 4294967260
put bitnot 52 produces 4294967243

Are these the expected results?

There's no left and right bitshift operators in RR/MC
so i'm using this function:

Function bitshiftleft
binarynumber,numberofbytestoshift
put the number of chars of binarynumber into binlength
repeat numberofbytestoshift
put "0" after binarynumber
end repeat
delete char 1 to numberofbytestoshift of binarynumber
return binarynumber
end bitshiftleft

Function bitshiftright binarynumber,bytestoshift
put the number of chars of binarynumber into binlength
repeat bytestoshift
put "0" before binarynumber
end repeat
delete char -(bytestoshift) to -1 of binarynumber
return binarynumber
end bitshiftright

The operators bitor, bitand, bitxor works as
expected, but i'm not fully aware of all it's
features or limitations. If you had worked 
before with binary numbers and bitwise operators,
i'll be highly gratefull of your help.

Thanks in advance!

al

=====
Visit my site:
http://www.geocities.com/capellan2000/
Search the mail list:
http://mindlube.com/cgi-bin/search-use-rev.cgi


	
		
__________________________________
Do you Yahoo!?
Friends.  Fun.  Try the all-new Yahoo! Messenger.
http://messenger.yahoo.com/ 


More information about the use-livecode mailing list