## Help me interpret an expression, please

Discussion of Scheme and Racket

### Help me interpret an expression, please

Hi all, I'm a beginner in Scheme programming and I don't understand the following expression:

(bitwise-arithmetic-shift #vu8(1 0 0 0) pin) where pin is usually the integer 0 to 31

Can you explain me step by step, what is the purpose of this expression and what is happening inside it, please?

I understand what e.g. (bitwise-arithmetic-shift #xHexNumber) means but I don't understand it in conjunction with the #vu8(1 0 0 0) (byte-vector???) in the above mentioned expression...

Thank you for your help...and please, take into consideration that I'm really a beginner...
jamsoft

Posts: 3
Joined: Fri Mar 02, 2012 10:54 am

### Re: Help me interpret an expression, please

#vu8 is merely a way of representing* a bit vector whereby each element of the list of values within the parentheses represents 8-bits of the bit vector. As a binary number, #vu8(1 0 0 0) is equivalent to a "1" followed by 24 zeros; as a decimal number it is the same as 256*256*256, or 2^24 (16,777,216).

* under the R6RS standard.
saulgoode

Posts: 45
Joined: Tue Dec 14, 2010 1:39 am

### Re: Help me interpret an expression, please

Thank you very much for your explanation.

So, for confirmation that I've understood well, e.g. - the #vu8(0 0 4 0) - considering that every element of the bit vector is 8-bit number it will be interpreted as 21 zeros followed by 1 and then followed by 10 zeros? (i.e. 00000000000000000000010000000000)?

Am I right?
jamsoft

Posts: 3
Joined: Fri Mar 02, 2012 10:54 am

### Re: Help me interpret an expression, please

Yes, I believe your understanding is correct.
saulgoode

Posts: 45
Joined: Tue Dec 14, 2010 1:39 am

### Re: Help me interpret an expression, please

Thank you! Your explanation helped me very much!
jamsoft

Posts: 3
Joined: Fri Mar 02, 2012 10:54 am

### Who is online

Users browsing this forum: No registered users and 0 guests