Boolean Data Type – Programming Fundamentals - Rebus Press
Maybe your like
Overview
A Boolean data type has one of two possible values (usually denoted true and false), intended to represent the two truth values of logic and Boolean algebra. It is named after George Boole, who first defined an algebraic system of logic in the mid 19th century. The Boolean data type is primarily associated with conditional statements, which allow different actions by changing control flow depending on whether a programmer-specified Boolean condition evaluates to true or false.[1]
Discussion
The Boolean data type is also known as the logical data type and represents the concepts of true and false. The name “Boolean” comes from the mathematician George Boole; who in 1854 published: An Investigation of the Laws of Thought. Boolean algebra is the area of mathematics that deals with the logical representation of true and false using the numbers 0 and 1. The importance of the Boolean data type within programming is that it is used to control programming structures (if then else, while loops, etc.) that allow us to implement “choice” into our algorithms.
The Boolean data type has the same attributes and acts or behaves similarly in all programming languages. However, while all languages recognize false as 0, some languages define true as -1 rather than 1. This is the result of storing the Boolean values as an integer and using a one’s complement representation that negates all bits rather than only the rightmost bit. To simplify processing, most programming languages recognize any non-zero value as being true.
| Language | Reserved Word | True | False |
|---|---|---|---|
| C++ | bool | true | false |
| C# | bool or Boolean | true | false |
| Java | bool | true | false |
| JavaScript | Boolean() | true | false |
| Python | bool() | True | False |
| Swift | Bool | true | false |
Key Terms
Boolean A data type representing the concepts of true or false. one’s complement The value obtained by inverting all the bits in the binary representation of a number (swapping 0s for 1s and vice versa).References
- cnx.org: Programming Fundamentals – A Modular Structured Approach using C++
- Wikipedia: Boolean data type ↵
License
Programming Fundamentals Copyright © 2018 by Authors and Contributors is licensed under a Creative Commons Attribution-ShareAlike 4.0 International License, except where otherwise noted.
Share This Book
Share on X Share on LinkedIn Share via EmailTag » What Is A Boolean Value
-
Boolean Values - IBM
-
What Is A Boolean Data Type, And What Are Some Uses? - SitePoint
-
Boolean Values
-
Boolean Variable - An Overview | ScienceDirect Topics
-
What Is A Boolean? - Computer Hope
-
What Is A Boolean? - Lifewire
-
True/False / Examples /
-
Boolean - JavaScript - MDN Web Docs
-
Boolean Or Truth Values - Analytica Wiki
-
Boolean Data Type - Visual Basic | Microsoft Learn
-
7.1. Boolean Values And Boolean Expressions - Runestone Academy
-
Boolean Data Type In Python - GeeksforGeeks
-
Learn Booleans In JavaScript