Toggle menu
Toggle preferences menu
Toggle personal menu
Not logged in
Your IP address will be publicly visible if you make any edits.

Boolean: Difference between revisions

From Coderwiki
create Boolean
 
m Boolean: fix incorrect formatting of states list
 
Line 5: Line 5:
Each boolean [[variable]] can represent one of two values:
Each boolean [[variable]] can represent one of two values:


- <code>true</code>
* <code>true</code>
- <code>false</code>
* <code>false</code>


== Storage ==
== Storage ==

Latest revision as of 22:16, 8 August 2025

Booleans are a type of data type found in almost all major programming languages.

Possible states

edit edit source

Each boolean variable can represent one of two values:

  • true
  • false

Theoretically, a boolean only needs to take up 1 bit in memory, as it only stores two values: true or false - or 1 or 0.

In most programming languages, however, a boolean may use more than one bit. This is because of data structure alignment and data structure padding - it's faster for the CPU to access data when it's stored in the same region.