dealing with bits and signed integers in Revolution

Trevor DeVore trevor at mangomultimedia.com
Wed Mar 19 18:19:00 EST 2003


I have been experimenting with reading in binary data and manipulating 
it.  This is my first attempt at dealing with binary data and I have a 
couple of questions that I was hoping someone with more experience in 
this area could help with.

1) I haven't found any way to do bitshifting (<< and >>).  Does Rev 
have an equivalent function?

2) In the files I have been reading in I have to deal with signed 15 
bit integers.  I need to be able to read these integers as base 10 
numbers and then convert base 10 numbers into a signed 15 bit integer.  
I wrote a small function that uses two's complement for reading them 
but I was wondering if there was an easier way?

3) The files I am reading store the information using Big-Endian.  
Let's says I was reading in a 4 byte unsigned integer.  Currently I am 
doing something resembling the following:
-- get binary data
binaryDecode("B8B8B8B8", myBinaryData, opt1, opt2, opt3, opt4)
-- Big-Endian conversion
put opt4 & opt3 & opt2 & opt1 into opt

It doesn't seem like this is the most efficient way to do this?  Any 
suggestions?

If anyone has tips on any of these items I would really appreciate it.

Thanks,

Trevor DeVore
Blue Mango Multimedia
trevor at mangomultimedia.com




More information about the use-livecode mailing list