Difference between revisions of "Boolean"

esse quam videri
Jump to: navigation, search
(Example)
 
(4 intermediate revisions by 2 users not shown)
Line 1: Line 1:
 
=Definition=
 
=Definition=
 
A variable having two possible values called “true” and “false.” It can be thought of as a binary value.
 
A variable having two possible values called “true” and “false.” It can be thought of as a binary value.
 +
 +
=What does this mean=
 +
Similar to how [[Base 2]] operates, Boolean also can only exist in 2 states, either 0 or 1. But in computer programming, we don't do any calculations with boolean. We simply tell the computer whether an element or condition is true or false.
  
 
=Relevance=
 
=Relevance=
 +
*[[Base 2]]
 
*[[Binary]]
 
*[[Binary]]
 
*[[Bit]]
 
*[[Bit]]
 +
 
=Explanation=
 
=Explanation=
  
Line 12: Line 17:
  
 
Boolean variables can be named with words and phrases that relate to a true/false conditional statement, such as “is,” “has,” etc.
 
Boolean variables can be named with words and phrases that relate to a true/false conditional statement, such as “is,” “has,” etc.
 +
 +
[[File:Lightbulb.png | 500 px]]
  
 
=Example=
 
=Example=
 
Here’s an example related to pizza:
 
Here’s an example related to pizza:
 +
<syntaxhighlight lang ="csharp">
 +
bool tastesGood = true;
 +
bool isCheesy = false;
 +
bool hasTomatoes = true;
 +
</syntaxhighlight>
 +
 +
Booleans are typically used for conditional statements!
 +
 +
<syntaxhighlight lang ="csharp">
 +
if(tastesGood == true)
 +
{
 +
    bool customerSatisfied = true;
 +
}
 +
</syntaxhighlight>
  
{| class="BoolTable"
+
=Note=
|-
+
Although it would be intuitive for a boolean to be a bit in size, booleans are really one byte in size. This is due to how computers access memory.
|bool tastesGood = true;
 
|-
 
|bool isCheesy = false;
 
|-
 
|bool hasTomatoes = true;
 
|-
 
|}
 
  
 
=Resources=
 
=Resources=
 +
https://docs.microsoft.com/en-us/office/vba/language/reference/user-interface-help/boolean-data-type
 +
 
== See also ==
 
== See also ==
 
 
* [[Binary]]
 
* [[Binary]]
 
* [[Data Type]]
 
* [[Data Type]]
 
==Notes==
 
 
  
 
==External Links==
 
==External Links==
 
https://en.wikipedia.org/wiki/Data_type
 
https://en.wikipedia.org/wiki/Data_type
 
  
 
[[Category:Programming Language Concepts]]
 
[[Category:Programming Language Concepts]]
 
[[Category:Object Oriented Programming]]
 
[[Category:Object Oriented Programming]]
 
[[Category:C Sharp]]
 
[[Category:C Sharp]]

Latest revision as of 15:39, 8 August 2019

Definition

A variable having two possible values called “true” and “false.” It can be thought of as a binary value.

What does this mean

Similar to how Base 2 operates, Boolean also can only exist in 2 states, either 0 or 1. But in computer programming, we don't do any calculations with boolean. We simply tell the computer whether an element or condition is true or false.

Relevance

Explanation

A boolean is a data type intended to represent the two truth values of logic and Boolean algebra.

In programming and coding, you can create your own boolean variable and set it to true or false by saying “bool (nameOfYourVariable) = true;”

Boolean variables can be named with words and phrases that relate to a true/false conditional statement, such as “is,” “has,” etc.

Lightbulb.png

Example

Here’s an example related to pizza:

bool tastesGood = true;
bool isCheesy = false;
bool hasTomatoes = true;

Booleans are typically used for conditional statements!

if(tastesGood == true)
{
    bool customerSatisfied = true;
}

Note

Although it would be intuitive for a boolean to be a bit in size, booleans are really one byte in size. This is due to how computers access memory.

Resources

https://docs.microsoft.com/en-us/office/vba/language/reference/user-interface-help/boolean-data-type

See also

External Links

https://en.wikipedia.org/wiki/Data_type