{{fbdoc item="title" value="BOOLEAN"}}----
Standard data type

{{fbdoc item="syntax"}}##
	[[KeyPgDim|dim]] //variable// [[KeyPgAs|as]] **Boolean**
##
{{fbdoc item="desc"}}
	Boolean data type. Can hold the values ##[[KeyPgTrue|True]]## or ##[[KeyPgFalse|False]]##
	Default value on initialization is ##[[KeyPgFalse|False]]##
	
	**Notes on definition of boolean data type:**
		//""-"" Ideally, the definition of the boolean data type is that it holds the value of ##[[KeyPgTrue|True]]## or ##[[KeyPgFalse|False]]##, and that's it. However, to make this concept a reality, we need a definition that uses real world connections.
		""-"" A more realistic definition is that the boolean data type is a 1-bit integer, having the value 0 to indicate ##[[KeyPgFalse|False]]## and 1 to indicate ##[[KeyPgTrue|True]]##.
		""-"" For a practical definition, we must consider, yet again, additional factors. The most significant factor is that the hardware (processor) on which code is executed does not directly support a 1-bit data type; the smallest register or memory size we can work with is 8-bits or 1-byte.
		""-"" Assume "false" is 0 in both C/C""++"" and FB.  C/C""++"" has logical 'not' operator '!' such that '!0' produces '1'.  FB has a bitwise ##[[KeyPgOpNot|Not]]## operator such that 'not 0' produces '-1'.
		""-"" Nevertheless the definition under the hood for a FB boolean remains an 1-bit integer, zero extended to fill larger integer types.
		""-"" Therefore when assigning a boolean with an integer value (by implicit conversion and not with the ##[[KeyPgFalse|False]]## or ##[[KeyPgTrue|True]]## value), '0' induces the ##[[KeyPgFalse|False]]## state and '1' or '-1' induces the ##[[KeyPgTrue|True]]## state (any other value also induces the ##[[KeyPgTrue|True]]## state, but with a warning message).
		""-"" Otherwise when assigning a numeric type with a boolean (by implicit conversion), ##[[KeyPgFalse|False]]## induces the '0' value and ##[[KeyPgTrue|True]]## induces the '-1' value.
		""-"" However, the purpose and intent of the boolean data type remains, that it should only ever hold a ##[[KeyPgTrue|True]]## value or ##[[KeyPgFalse|False]]## value, regardless of the underlying details.//

{{fbdoc item="ex"}}
	{{fbdoc item="filename" value="examples/manual/datatype/boolean.bas"}}%%(freebasic)
Dim boolvar As Boolean
boolvar = True
Print "boolvar = ", boolvar
%%
	Output:
		%%
boolvar =     true
%%
{{fbdoc item="ver"}}
	- Since fbc 1.04.0

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

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

{{fbdoc item="see"}}
	- ##[[KeyPgCbool|Cbool]]##
	- ##[[KeyPgTrue|True]]##
	- ##[[KeyPgFalse|False]]##
	- ##[[TblVarTypes|Table with variable types overview, limits and suffixes]]##

{{fbdoc item="back" value="CatPgStdDataTypes|Standard Data Types"}}