Type bool

Variables of type int can have billions of possible values, and those of type char can have 256. Variables of type bool can have only two possible values: true and false. In theory a bool type requires only one bit (not byte) of storage, but in practice compilers often store them as integers because an integer can be quickly accessed, while an individual bit must be extracted from an integer, which requires additional time.

Type bool is most commonly used to hold the results of comparisons. Is alpha less than beta? If so, a bool value is given the value true; if not, it’s given the value false.

Type bool gets its name from George Boole, a 19th century English mathematician who invented the concept of using logical operators with true-or-false values. Thus such true/false values are often called Boolean values.

  © Free Blogger Templates Modic Template by For more Information : click Here

Back to TOP