Access the NEW Basecamp Support Portal

Boolean data type

« Back to Glossary Index

Generalities about Boolean Data Type
– Programming languages like Pascal and Java have a built-in Boolean data type.
– Comparison operators like ‘and’ are defined to return a Boolean value.
– Conditional and iterative commands are used to test Boolean-valued expressions.
– Some languages like C90 and Lisp represent truth values using other data types.
– Booleans can be implemented as numerical variables with one binary digit or as bit strings of length one.

Boolean Data Type in Programming Languages
– Fortran:
– The first versions of FORTRAN had no logical values or operations.
– FORTRAN IV introduced a Boolean data type, logical literals, and logical operators.
– FORMAT statements in FORTRAN have specific format descriptors for parsing or formatting logical values.
– Later languages like Modula, Ada, and Haskell adopted the Boolean data type derived from FORTRAN.
– FORTRAN uses a BIT(1) representation for Boolean values.
– C, C++, Objective-C, AWK:
– Initial implementations of C did not have a Boolean type, using integers instead.
– ANSI C added enumerated types, allowing programmers to define their own Boolean types.
– Standard C introduced the _Bool type, which can be used with the bool name and true/false constants.
– C++ has a separate bool data type with automatic conversions from scalar and pointer values.
– Objective-C has a separate BOOL data type, but can also use the _Bool type from C.
– PL/I:
– PL/I does not have a Boolean data type.
– Comparison operators in PL/I generate BIT(1) values, with 0B representing false and 1B representing true.
– Operations on PL/I BIT(1) values are performed on each bit.
– The element-expression of an IF statement in PL/I is true if any bit is 1.
– Rexx:
– Rexx does not have a Boolean data type.
– Comparison operators in Rexx generate 0 or 1, with 0 representing false and 1 representing true.
– Rexx operands must be 0 or 1 for comparison operators.
– Tcl:
– Tcl does not have a separate Boolean type.
– Like in C, integers 0 (false) and 1 (true) are used in Tcl.
– Tcl expressions that evaluate to 1 are considered true.

Introduction and Implementation of BOOLEAN data type in SQL:1999
– SQL:1999 standard introduced BOOLEAN data type as an optional feature.
– Introduced IS (NOT) TRUE, IS (NOT) FALSE, and IS (NOT) UNKNOWN operators.
– SQL BOOLEAN behaves like Booleans in other languages, storing TRUE and FALSE values.
– Nullable BOOLEAN can have the special null value.
– SQL standard defines three literals for BOOLEAN type: TRUE, FALSE, and UNKNOWN.
– Few major SQL systems implement the BOOLEAN feature as of 2012.
– Firebird and PostgreSQL are exceptions, with PostgreSQL using NULL instead of UNKNOWN.
– Microsoft SQL Server does not support BOOLEAN, using BIT data type as a workaround.
– Microsoft Access also uses BIT data type instead of BOOLEAN.
– PostgreSQL has a distinct BOOLEAN type as in the standard.

Treatment of BOOLEAN values in different SQL systems
– Microsoft SQL Server does not support BOOLEAN as a standalone data type.
– Microsoft Access represents TRUE as 1 and does not support the Null tri-state.
– PostgreSQL allows storing predicates directly into a BOOLEAN column.
– MySQL treats BOOLEAN as an alias of TINYINT(1), with non-zero integers considered true.
– Tableau Software has a BOOLEAN data type with True and False literals.

BOOLEAN representation in Forth programming language
– Forth does not have a Boolean type, using regular integers for true and false.
– Value 0 represents false, while -1 represents true in Forth.
– Forth uses one set of logical operators for both mathematical calculations and conditions.

Related topics and references:
– Boolean differential calculus, flag programming, Shannons expansion, three-valued logic, and true/false commands for shell scripting are related topics.
– References include books, programming language documentation, and online tutorials for various languages and SQL systems.

Boolean data type (Wikipedia)

In computer science, the Boolean (sometimes shortened to Bool) is a data type that has one of two possible values (usually denoted true and false) which is 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. It is a special case of a more general logical data type—logic does not always need to be Boolean (see probabilistic logic).

« Back to Glossary Index

Request an article

Please let us know what you were looking for and our team will not only create the article but we'll also email you to let you know as soon as it's been published.
Most articles take 1-2 business days to research, write, and publish.
Content/Article Request Form

Submit your RFP

We can't wait to read about your project. Use the form below to submit your RFP!
Request for Proposal

Contact and Business Information

Provide details about how we can contact you and your business.

Quote Request Details

Provide some information about why you'd like a quote.