BITCLEAR( ) Function

Clears the specified bit in a Numeric, Varbinary, or Blob value by setting it to 0 and returns the resulting value. There is a numeric and a binary version of the syntax.

Note

If the specified expression is not an integer, it is converted to an integer before performing the operation.

BITCLEAR(nNumericExpression1, nNumericExpression2)

BITCLEAR(BinaryExpression [, nStartBit [, nBitCount]])

Parameters

  • nNumericExpression1
    Specifies the Numeric value to clear the bit in. If the expression is not an integer, it is converted to an integer before setting the bit.

  • nNumericExpression2
    Specifies the bit position in nExpression1 to clear. nExpression2 can range from 0 to 31 with 0 located as the bit to the farthest right.

  • BinaryExpression
    Specifies a Varbinary or Blob expression.

  • [ nStartBit[, nBitCount]]
    Specifies a starting zero-based number of the first bit to perform the operation as nStartBit and the number of bits to perform the operation as nBitCount.

    If you do not specify nStartBit and nBitCount, the operation applies to all bits in the expression. If you specify nStartBit only, the operation applies to nStartBit only.

Return Value

Numeric, Varbinary, or Blob. BITCLEAR( ) returns the specified expression without specified bit.

Example

x = 7  && 0111 binary
y = 1  && 2nd bit position (0 = 1st bit position)
? BITCLEAR(x,y) && Returns 5, 0101 binary

See Also

Reference

BITAND( ) Function

BITLSHIFT( ) Function

BITNOT( ) Function

BITOR( ) Function

BITRSHIFT( ) Function

BITSET( ) Function

BITTEST( ) Function

BITXOR( ) Function

Other Resources

Functions

Language Reference (Visual FoxPro)