Click or drag to resize

BitTest Function (Binary, Long)

X#
Determines whether a specific bit in a Numeric, Varbinary, or Blob value is set to 1. There is a numeric and a binary version of the syntax. If the specified expression is not an integer, it is converted to an integer before performing the operation.

Namespace:  XSharp.VFP
Assembly:  XSharp.VFP (in XSharp.VFP.dll) Version: 2.21
Syntax
 FUNCTION BitTest(
	BinString AS BINARY,
	BitNumber AS LONG
) AS LOGIC
Request Example View Source

Parameters

BinString
Type: Binary
Specifies a Varbinary or Blob expression to check for the specified bit.
BitNumber
Type: Long
Specifies a zero-based bit in BinString. If nBitNumber is out of range of BinString, X# generates an error.

Return Value

Type: Logic
Logical. BitTest( ) returns True (.T.) if the specified bit is set to 1; otherwise, it returns False (.F.).
Examples
X#
 1Clear
 2? '2 even? '
 3?? IsEven(2)  // Even, .T. returned
 4? '3 even? '
 5?? IsEven(3)  // Not even, .F. returned
 6? '0 even? '
 7?? IsEven(0)  // Even, .T. returned
 8? '-13 even? '
 9?? IsEven(-13)  // Not even, .F. returned
10Function IsEven
11PARAMETER nInteger
12RETURN NOT BitTest(nInteger, 0)
See Also