{{fbdoc item="title" value="BIT"}}----
Gets the state of an individual bit in an integer value.

{{fbdoc item="syntax"}}##
	[[KeyPgPpdefine|#define]] **Bit**( //value//, //bit_number// ) (((//value//) [[KeyPgOpAnd|and]] ([[KeyPgCast|Cast]]([[KeyPgTypeof|TypeOf]](//value//), 1) [[KeyPgOpShiftLeft|shl]] (//bit_number//))) <> 0)
##
{{fbdoc item="usage"}}##
	//result// = **Bit**( //value//, //bit_number// )
##
{{fbdoc item="param"}}
	##//value//##
		The integer value.
	##//bit_number//##
		The index of the bit.

{{fbdoc item="ret"}}
	Returns an ##[[KeyPgInteger|Integer]]## value of ##-1## if the bit is set, or ##0## if the bit is cleared.

{{fbdoc item="desc"}}
	This macro expands to an integer value indicating whether or not the bit specified by ##//bit_number//## is set in the integer ##//value//##. Behaves as `##(//value// [[KeyPgOpAnd|And]] 1 [[KeyPgOpShiftLeft|Shl]] //bit_number//) <> 0##`.
	
	The valid range of values for ##//bit_number//## depends on the size, in bits, of `##[[KeyPgTypeof|Typeof]](//value//)##`, which is `##0##` (from the lowest bit) through `##[[KeyPgSizeof|Sizeof]](//value//) * 8 - 1##` (up to the highest bit). See [[TblVarTypes|Standard Datatype Limits]] for a table of the standard datatypes and their sizes.

{{fbdoc item="ex"}}
{{fbdoc item="filename" value="examples/manual/bits/bit.bas"}}%%(freebasic)
PRINT BIT(4,2)
PRINT BIT(5,1)
PRINT BIT(&H8000000000000000ULL,63)
%%
	will produce the output:

%%
-1
0
-1
%%

{{fbdoc item="lang"}}
	- Not available in the //[[CompilerOptlang|-lang qb]]// dialect unless referenced with the alias ##**""__Bit""**##.

{{fbdoc item="diff"}}
	- New to ""FreeBASIC""

{{fbdoc item="see"}}
	- ##[[KeyPgBitset|Bitset]]##
	- ##[[KeyPgBitreset|Bitreset]]##

{{fbdoc item="back" value="CatPgBits|Bit Manipulation"}}