<<

Contents

Search

>>

 

BIT

 

 

Function

 

 

Syntax:

BIT(<Number>,<Start-Position>,<End-Position>)

 

<Number>

= <NUM-EXPRESSION>

<Start-Position>

= <NUM-EXPRESSION>

<End-Position>

= <NUM-EXPRESSION>

 

Meaning:

Returns the value of a single bit or of several bits of the number <Number>.

 

The number of bits is specified by <Start-Position> and <End-Position>.

 

<Start-Position> must be <= <End-Position> otherwise BIT returns -1.

 

Attention: The bits are counted from right to left beginning with 0.

 

Parameter:

Number

Numeric expression

Start-Position

Number of the first bit (counted from right beginning with 0)

End-Position

Number of the last bit (counted from right beginning with 0)

 

Sample:

The bits of number 89 are: 1 0 1 1 0 0 1
The lowest-order bit is on the right.

 

BIT(89,0,0) returns 1

BIT(89,1,1) returns 0

BIT(89,2,2) returns 0

BIT(89,3,3) returns 1

BIT(89,4,4) returns 1

BIT(89,5,5) returns 0

BIT(89,6,6) returns 1

BIT(89,1,4) returns 12: This is the value of bits 1 to 4: 1 1 0 0

 

See also:

BIT_SHIFT_LEFT

BIT_SHIFT_RIGHT

BIT_AND

BIT_OR

BIT_XOR

BIT_CMP