Boolean values: Difference between revisions

Content deleted Content added
CalmoSoft (talk | contribs)
mNo edit summary
No edit summary
Line 716: Line 716:
IF-statement, loop condition treats any non-zero integer as true.
IF-statement, loop condition treats any non-zero integer as true.
Comparison operators evaluate to 1 (true) or 0 (false).
Comparison operators evaluate to 1 (true) or 0 (false).

=={{header|Little}}==
For conditionals, numeric variables (including poly variables
with a number in them), evaluate to true or false based on
their value

Use the defined() buildin to test if a variable is defined.

For the rest of variable types the value depend if the variable
is defined or not.


<lang C>int a = 0;
int b = 1;
int c;
string str1 = "initialized string";
string str2; // "uninitialized string";

if (a) {puts("first test a is false");} // This should not print
if (b) {puts("second test b is true");} // This should print
if (c) {puts("third test b is false");} // This should not print
if (!defined(c)) {puts("fourth test is true");} // This should print
if (str1) {puts("fifth test str1 is true");} // This should print
if (str2) {puts("sixth test str2 is false");} // This should not print</lang>



=={{header|LiveCode}}==
=={{header|LiveCode}}==