### Datatype bool

This is the easiest type. A boolean expresses a truth value. It can be either TRUE or FALSE.

Syntax

To specify a boolean literal, use either the keyword TRUE or FALSE. Both are case-insensitive.

`  bFlag = true; // assign the value TRUE to bFlag  `

Usually you use some kind of operator which returns a boolean value, and then pass it on to a control structure.

`  // == is an operator which returns a boolean  if (action == 1)  {          z=sqrt(z*sin(c));  }    // this is not necessary:  if (bFlag == TRUE)  {          return(sin(z));  }    // because you can simply type this:  if (bFlag)  {          return(sin(z));  }   `

Converting to/from boolean

Boolean values are automatically converted to another datatype. Internally a boolean is simply an integer:

TRUE is 1
FALSE is 0

So you can do calculations with booleans:

`  real b;  complex c;  bool bFlag;    	bFlag=true;  	c=(1,2);          b=c*bFlag; // bFlag will be converted to 1, so (1,2)*1=(1,2), converting to real results in 1          bFlag=false;          b=c*bFlag; // bFlag will be converted to 0, so (1,2)*0=(0,0), converting to real results in 0  `

ChaosPro not only converts boolean values to other datatypes, but also it converts other datatypes to booleans if needed.

The basic idea is:
TRUE is any value other than 0. FALSE is 0.

consider the following if-statement:

`     if (d)     {     	z=4;     }  `

Now when will d be true and when will d be false? The following table lists all possible datatypes for a variable named d and explains when the if condition evaluates to true and thus z will be 4:

 Datatype of d TRUE FALSE quaternion True if any component of the quaternion number is not zero. False only if all 4 components of the quaternion number are zero. complex True if real or imaginary part of complex number is not zero. False only if real part as well as imaginary part of complex number is zero. real True if not zero. False if zero. int True if not zero. False if zero. bool True if true False if false