devxlogo

Boolean Literals

Boolean Literals

The keywords false and true are Boolean literals that evaluate to 0 and 1 respectively. Note that in other programming language, VB for instance, false equals -1 and true equals 1. C++ programmers who write code that interfaces with other environments and languages such as Access are surprised to discover that all the bool values retrieved from a database evaluate to true. The problem is that any non-zero value, including negative values, evaluates as true in C++. Therefore, don’t assume that true and false have the same representation in all languages and environments.

devx-admin

Share the Post: