| Applying science to business management |
  
Boolean Values
Boolean data has one of only two values, true or false.
Some operators and primitives return Boolean values. For example,
the statement 1==2 will return false.
Boolean values are used in control structures such as the if statement.
All primitives that require a Boolean value as an input will
also accept a numeric or text value. The number zero is converted
to the Boolean value false and all other numbers are
converted to true. In addition, all text strings other
than the empty string are converted to true.
Each of the following data items is converted to true
when evaluated as a Boolean value:
true
1
2.3
"text"
Similarly, each of the following items is converted to false:
false
0
""
null
All primitives that require a number as an input will accept a
Boolean value as well. The value true is converted to one
and false is converted to zero. For example, the statement
true+1 will return 2.
|