This is a read-only archive of lispforum.com. The forum was locked to new users and posts and is preserved here as static HTML from a database snapshot taken on 2019-09-07.

Help me interpret an expression, please

5 posts · 8637 views

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... :-)

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.

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?

Re: Help me interpret an expression, please

Yes, I believe your understanding is correct.

Re: Help me interpret an expression, please

Thank you! Your explanation helped me very much!