[prev] 12 [next]

Boolean Expressions

Boolean expressions in C are short circuit

(Cond1 && Cond2 && ... && Condn)

Evaluates by

  • evaluate Cond1; if 0 then return 0 for whole expression
  • evaluate Cond2; if 0 then return 0 for whole expression
  • ...
  • evaluate Condn; if 0 then return 0 for whole expression
  • otherwise, return 1
In C, any non-zero value is treated as true; MIPS tends to use 1 for true

C99 standard defines return value for booleans expressions as 0 or 1