Jump to content

Boolean values: Difference between revisions

m
Line 8:
=={{header|AutoHotkey}}==
When an expression is required to evaluate to true or false (such as an IF-statement), a blank or zero result is considered false and all other results are considered true. Operators such as NOT/AND/OR/>/=/< automatically produce a true or false value: they yield 1 for true and 0 for false. A variable can be used to hold a false value simply by making it blank or assigning 0 to it. The words 'true' and 'false' are built-in variables containing 1 and 0. They can be used to make a script more readable.
 
=={{header|ALGOL 68}}==
{{trans|python}}
 
{{works with|ALGOL 68|Standard - no extensions to language used}}
 
{{works with|ALGOL 68G|Any - tested with release [http://sourceforge.net/projects/algol68/files/algol68g/algol68g-1.18.0/algol68g-1.18.0-9h.tiny.el5.centos.fc11.i386.rpm/download 1.18.0-9h.tiny]}}
{{wont work with|ELLA ALGOL 68|Any (with appropriate job cards) - note: null char is missing, AND the C generated is won't compile, so some conversions are missing from RS}}
ALGOL 68 Enforces strong typing and so has few default coersions. The appropriate operators must be used to convert to and from BOOLean. The following code demonstrate the common conversions:
<lang algol68>BOOL f = FALSE, t = TRUE;
[]BOOL ft = (f, t);
FOR key TO UPB ft DO
BOOL val = ft[key];
UNION(VOID, INT) void = (val|666|EMPTY);
REF STRING ref = (val|HEAP STRING|NIL);
INT int = ABS val;
REAL real = ABS val;
COMPL compl = ABS val;
CHAR char = (val|"?"|null char);
STRING string=(val|"?"|"");
BITS bits = bitspack(val);
 
print((((val | "TRUE" | "FALSE" ), ": ", val, " OR ", (val|flip|flop), new line)));
print((" void: ", (void|(VOID):FALSE|TRUE), new line));
print((" ref: ", ref ISNT REF STRING(NIL), new line));
print((" int: ", int , " => ", int /= 0, new line));
print((" real: ", real , " => ", real /= 0, new line));
print((" compl: ", compl , " => ", compl /= 0, new line));
print((" char: """, char , """ => ", ABS char, " OR ", char /= null char, new line));
print(("string: """, string , """ => ", string /= "", " OR ", UPB string /= 0, new line));
print((" bits: ", bits , " => ", bits width ELEM bits, " OR ", []BOOL(bits)[bits width]));
TO 2 DO print((new line)) OD
OD</lang>
Output:
<pre>FALSE: F OR F
void: F
ref: F
int: +0 => F
real: +0.00000000000000e +0 => F
compl: +0.00000000000000e +0+0.00000000000000e +0 => F
char: "" => +0 OR F
string: "" => F OR F
bits: FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF => F OR F
 
TRUE: T OR T
void: T
ref: T
int: +1 => T
real: +1.00000000000000e +0 => T
compl: +1.00000000000000e +0+0.00000000000000e +0 => T
char: "?" => +63 OR T
string: "?" => T OR T
bits: FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFT => T OR T
</pre>
 
=={{header|AWK}}==
Cookies help us deliver our services. By using our services, you agree to our use of cookies.