lsh
 
 
 

Returns the logical bitwise shift of an integer by a specified number of bits

(lsh intnumbits) 

Arguments

int

An integer.

numbits

Number of bits to shift int.

If numbits is positive, int is shifted to the left; if numbits is negative, int is shifted to the right. In either case, zero bits are shifted in, and the bits shifted out are discarded.

If numbits is not specified, no shift occurs.

Return Values

The value of int after the bitwise shift. The returned value is positive if the significant bit (bit number 31) contains a 0 after the shift operation; otherwise it is negative. If no arguments are supplied, lsh returns 0.

The behavior is different from other languages (>> & << of C, C++, or Java) where more than 32 left shifts (of a 32 bit integer) result in 0. In right shift, the integer appears again on every 32 shifts.

Examples

Command: (lsh 2 1)

4

Command: (lsh 2 -1)

1

Command: (lsh 40 2)

160