Boolean variable
Boolean variables , named after George Boole , are elements of a Boolean algebra . A special form with only two states in the digital technology , the switching variable ( English switching variable ) or the programming of the boolean data type .
Basics: Boolean mathematics and switching algebra
A Boolean variable in general is a variable that can only assume a finite number of values or states: With his work The Mathematical Analysis of Logic from 1847, George Boole laid the foundation for formal logic and computing technology. The set of these values forms a character set .
Special type Boolean algebra is the Boolean algebra , the switching variable can only assume one of a few values:
- Here they are mostly two-valued (binary) Boolean variables - in technical terminology, a Boolean variable is generally understood to be a switching variable in the narrower sense. Depending on the application, this dichotomous pair of values is referred to as
wahr/falsch
ortrue/false
( statement variable ), or1/0
( binary number ). In electronic data processing , the two values are represented with voltage or current levels:HIGH, H
or or1
orLOW, L
or0
(zero) - as a circuit corresponds toEin/Aus
that or–1/1
to what corresponds to a flip-flop . - In addition, there are often three-value switching variables in the form
–1/0/1
(mathematically a signed single-digit binary number or a ternary number system0/1/2
), e.g.HIGH/NULL/LOW
in control engineering (VORWÄRTS/STOPP/RÜCKWÄRTS
). Boolean or switching algebra is in principle possible using any character set (range of values).
Digital technology
In digital technology, Boolean variables are implemented using different electrical voltage ranges. The specific voltage limits depend on the technology used (e.g. transistor-transistor logic or CMOS ).
programming
In the field of software development, a Boolean variable is a variable that can only assume two states. These states are called True and False (English for true and false ) and are also called truth values . Such variables can be logically linked with one another and are usually used for conditional instructions or loops.
Many programming languages provide their own data type, for example under the designation boolean ( Pascal , Java , Lua , Ada , Visual Basic Classic , BASIC ) or bool ( C # , C ++ , PHP , Python ) or logical ( Fortran ).
In principle, a single bit is sufficient to represent a Boolean variable to represent both possible variable states. For technical reasons, however, a different representation is usually chosen, mostly depending on the word length of the system used, with C ++ vectors being optimized for this type.
The representation as an integer depends on the environment. If a Boolean variable is represented with an integer type, 0 stands for false and anything not equal to zero (often -1 or 1 is used) for true . It is different in Linux / Unix shell programming. Here a value greater than zero stands for an error and, in the figurative sense, for false , while zero stands for a successful program call and thus for true .
Web links
- J. Donald Monk: The Mathematics of Boolean Algebra. In: Edward N. Zalta (Ed.): Stanford Encyclopedia of Philosophy .