QB64.com

QB64 is a modern extended BASIC programming language that retains QBasic/QuickBASIC 4.5 compatibility and compiles native binaries for Windows, Linux, and macOS.

The _READBIT function is used to check the state of a specified bit of a integer value.

Syntax

result = _READBIT(numericalVariable, numericalValue)

Parameter(s)

Description

Availability

Example(s)


A~%% = _SETBIT(A~%%,4)
PRINT "Bit 4 is currently ";
IF _READBIT(A~%%,4) = -1 THEN PRINT "ON" ELSE PRINT "OFF"
PRINT "And bit 2 is currently ";
IF _READBIT(A~%%,2) = -1 THEN PRINT "ON" ELSE PRINT "OFF"


Bit 4 is currently ON
And bit 2 is currently OFF


B& = 12589575
PRINT "B& ="; B&
FOR I%% = 31 TO 0 STEP -1 '32 bits for a LONG value
 Binary$ = Binary$ + LTRIM$(STR$(ABS(_READBIT(B&, I%%))))
NEXT I%%
PRINT "B& in binary is: "; Binary$


B& = 12589575
B& in binary is: 00000000110000000001101000000111

See Also