Frequently Asked Questions

How does the compiler determine TRUE and FALSE on expressions?

When relational expressions are assigned to variables, the result is always 0 or 1. For Example:

bytevar = 5 > 0; //bytevar will be 1 
bytevar = 0 > 5; //bytevar will be 0

The same is true when relation operators are used in expressions. For Example:

bytevar = (x > y)*4;

is the same as:

if( x > y ) 
   bytevar=4;
else
   bytevar=0; 

SHORT INTs (bit variables) are treated the same as relational expressions. They evaluate to 0 or 1. When expressions are converted to relational expressions or SHORT INTs, the result will be FALSE (or 0) when the expression is 0, otherwise the result is TRUE (or 1). For Example:

bytevar = 54; 
bitvar = bytevar; //bitvar will be 1 (bytevar ! = O)
		
if(bytevar) //will be TRUE 
   bytevar = 0; 
	
bitvar = bytevar; //bitvar will be 0