3.5.11.4 BitRShift

Description

Shift a given decimal number num right by the specified number of bits shift. It is proceeded as follows: firstly convert num into its binary representation, remove shift digits from the rightmost digit of the binary, and then convert it back to the decimal number. For example, BitRShift (4,2) converts 4 into "100" (its binary value), removes the last 2 digits so it become 1 in binary, and then convert 1 (binary value) to 1 in decimal.

Syntax

__int64 BitRShift( __int64 num, __int64 shift)

Parameters

num

The number in the decimal representation. It must be a non-negative integer.

shift

The number of bits by which to shift num right. It should be a non-negative integer. If a negative value is given, it will return the same value as the absolute value of shift of the BitLShift function.

Return

Returns a number shifted right by the specified number of bits.

Example

EX1

BitRShift(100, 2) = ;  // returns 25

EX2

i=hex(F1101010101); 
j=hex(F2010101011);
Dec2hex(bitRShift(i,3),12)$=;// 01E220202020

See Also

BitLShift