NIBBLE

Purpose:

Extracts a 4 bit nibble from a value.

Syntax:

NIBBLE(val, num, bitpos)

val

-

A scalar, series or table.

num

-

Optional. An integer, the nibble to retrieve. Defaults to 1 (the first four bits).

bitpos

-

Optional. An integer. Bit position. bitpos: 1 then num refers to starting LSB BIT position, else num refers to 4 bit nibble boundary. Defaults to 0.

Returns:

A series or number.

Example:

nibble(7+16)

 

Returns 7, the value of the first 4 bits.

Example:

nibble(7+16, 2)

 

Returns 1, the value of the second 4 bits.

Example:

nibble(7+16, 2, 1)

 

Returns 11, the value of the 4 bits starting at the 2nd bit, where the 2nd bit is the least significant bit - i.e. the value of bits 2 through 6.

Remarks:

Nibble also operates on series.

See Also:

>> << & ~ bitor (Bit Operators)