Scilab Bag Of Tricks: The Scilab-2.5.x IAQ (Infrequently Asked Questions) | ||
---|---|---|
Prev | Chapter 4. Unknown Spots | Next |
For the logical operators have boolean expressions as their arguments, it is time now to discuss the implicit promotion of numeric types to boolean type, something very familiar to C, Perl, and Python programmers. You have guessed right, the rule is: "Zero is false, everything else is true." Here are some examples of that rule at work:
-->%t & 0 ans = F -->%t & 0.1 ans = T -->6.34 | %f ans = T -->6.34 | -0.3 ans = T
Scilab always evaluates boolean expressions completely. No operator is defined with short-circuit evaluation semantics.
-->deff('b = ret_false()', 'b = %f, disp(''ret_false'')'); -->ret_false() & ret_false() ret_false ret_false ans = F