Boolean values: Difference between revisions

Rename Perl 6 -> Raku, alphabetize, minor clean-up
(Rename Perl 6 -> Raku, alphabetize, minor clean-up)
Line 28:
=={{header|8th}}==
In 8th, any non-zero number is true, as is the specific boolean value 'true'. Everything else evaluates as 'false' (including the boolean value, 'false')
 
=={{header|AArch64 Assembly}}==
{{works with|as|Raspberry Pi 3B version Buster 64 bits}}
Line 82 ⟶ 83:
.include "../includeARM64.inc"
</lang>
 
=={{header|ACL2}}==
Same as [[Common Lisp|Boolean Values#Common Lisp]].
Line 343 ⟶ 345:
110 END</lang>
 
==={{Headerheader|BaCon}}===
<lang qbasic>' Boolean TRUE and FALSE are non-zero and zero constants
a = TRUE
Line 376 ⟶ 378:
print true
</lang>
 
 
=={{header|Batch File}}==
Line 441 ⟶ 442:
* in C99, the boolean type <code>bool</code> (defined in header <tt><stdbool.h></tt>), where <code>true</code> gives true and <code>false</code> gives false
* in C99, any [[Complex numbers|complex number]] type, where 0 (0 real and 0 imaginary) gives false, anything else gives true
 
=={{header|C sharp|C#}}==
In C#, there are the reserved keywords <code>true</code> and <code>false</code>. Variables to hold these values are declared as either <code>bool</code> or <code>Boolean</code>. These types are identical, as <code>bool</code> is just shortand for <code>Boolean</code>. The collection type <code>BitArray</code> returns its values as <code>Boolean</code>, packing 8 values into each byte (In contrast, the <code>Boolean</code> type uses the entire byte for one value).
 
Unlike C/C++, there is no conversion in C# between other types and <code>Boolean</code>.
 
=={{header|C++}}==
Line 449 ⟶ 455:
* any pointer type, where the null pointer gives false and any other pointer gives true
* any user-defined type with an implicit conversion operator either to <code>bool</code> or to a built-in type which itself can be converted to <code>bool</code> (i.e. any of the above). The C++ standard library contains one such implicit conversion: the implicit conversion of a stream <code>s</code> to <code>bool</code> gives <code>!s.fail()</code>
 
=={{header|C sharp|C#}}==
In C#, there are the reserved keywords <code>true</code> and <code>false</code>. Variables to hold these values are declared as either <code>bool</code> or <code>Boolean</code>. These types are identical, as <code>bool</code> is just shortand for <code>Boolean</code>. The collection type <code>BitArray</code> returns its values as <code>Boolean</code>, packing 8 values into each byte (In contrast, the <code>Boolean</code> type uses the entire byte for one value).
 
Unlike C/C++, there is no conversion in C# between other types and <code>Boolean</code>.
 
=={{header|Clean}}==
Line 580 ⟶ 581:
]
</lang>
 
 
=={{header|Common Lisp}}==
Line 615:
=={{header|Delphi}}==
In addition to the types defined by [[#Object Pascal|Object Pascal]], Delphi defines the type <code>Bool</code>.
 
=={{header|Déjà Vu}}==
 
Déjà Vu has <code>true</code> and <code>false</code>, two numbers that are equal to 1 and 0 respectively. Every object has a truth value. The only falsy things are numbers equal to zero, empty lists and dictionaries, and zero-length strings and blobs.
 
=={{header|DWScript}}==
Line 631 ⟶ 627:
#f // <boolean> false</lang>
For the purpose of conditional statements, all objects other than <tt>#f</tt> evaluate to true.
 
=={{header|Déjà Vu}}==
 
Déjà Vu has <code>true</code> and <code>false</code>, two numbers that are equal to 1 and 0 respectively. Every object has a truth value. The only falsy things are numbers equal to zero, empty lists and dictionaries, and zero-length strings and blobs.
 
=={{header|E}}==
Line 663:
(not 0) → #f
</lang>
 
 
 
=={{header|EGL}}==
Line 706 ⟶ 704:
myInt: true
</pre>
 
 
=={{header|Elena}}==
Line 841 ⟶ 838:
TYPE(MIXED) STUFF</lang>
Except that now only hundred-element variables of type MIXED can be declared. Either way, the record size needed for a disc file holding such items will need careful thought.
 
=={{header|Free Pascal}}==
In addition to the types defined by [[#Object Pascal|Object Pascal]], free Pascal defines the <code>qWordBool</code>, that has a <code>sizeOf</code> eight.
 
=={{header|FreeBASIC}}==
Line 877:
-1
</pre>
 
=={{header|Free Pascal}}==
In addition to the types defined by [[#Object Pascal|Object Pascal]], free Pascal defines the <code>qWordBool</code>, that has a <code>sizeOf</code> eight.
 
=={{header|Futhark}}==
Line 1,097 ⟶ 1,094:
* String: the empty (zero-length) string is <code>false</code>; otherwise <code>true</code>
`
 
=={{header|Kotlin}}==
Booleans in Kotlin are given by the literals true and false, case sensitive, which are the only instances of the class Boolean.
Line 1,269 ⟶ 1,267:
=={{header|Mathematica}}==
True and False are the default boolean values.
To make any expression a boolean use the Boole[] function.
 
=={{header|MATLAB}}==
The keywords "true" and "false" are the default boolean values.
Line 1,331 ⟶ 1,329:
Metafont has the type <tt>boolean</tt>; a boolean variable can be <tt>true</tt> or <tt>false</tt>.
Using non boolean values (or expressions that do not evaluate to a boolean value) results in a recoverable error; by default, any non-boolean value is interpreted as false.
 
=={{header|Microsoft Small Basic}}==
Microsoft Small Basic has two constants: <code>"True"</code> and <code>"False"</code>.<br>
<lang smallbasic>If c Then
notc = "False"
Else
notc = "True"
EndIf</lang>
 
=={{header|min}}==
Line 1,506 ⟶ 1,512:
$istrue(0) tests false
$istrue(1) tests true</pre>
 
 
=={{header|Nemerle}}==
Line 1,546 ⟶ 1,551:
0 is false
</pre>
 
=={{header|Microsoft Small Basic}}==
Microsoft Small Basic has two constants: <code>"True"</code> and <code>"False"</code>.<br>
<lang smallbasic>If c Then
notc = "False"
Else
notc = "True"
EndIf</lang>
 
=={{header|Nim}}==
Line 1,574 ⟶ 1,571:
=={{header|Objeck}}==
Objeck has a <tt>Bool</tt> type that is set to either <tt>true</tt> or <tt>false</tt>. By default boolean types are initialized to <tt>false</tt>. The boolean type also allows methods to be invoked, which perform simple conversions or print given values.
 
=={{header|Objective-C}}==
Objective-C follows pretty much the same rules as C. In addition to C, Objective-C has a <code>BOOL</code> boolean type, with values <code>YES</code> for true and <code>NO</code> for false. Objective-C also adds several special types of pointers; for pointers to objects (values of type <code>id</code>), the <code>nil</code> pointer is false, everything else is true; for pointers to classes (values of type <code>Class</code>), the <code>Nil</code> pointer is false, everything else is true.
 
=={{header|Object Pascal}}==
Line 1,586 ⟶ 1,580:
 
''See also [[#Delphi|Delphi]] and [[#Free Pascal|Free Pascal]]''
 
=={{header|Objective-C}}==
Objective-C follows pretty much the same rules as C. In addition to C, Objective-C has a <code>BOOL</code> boolean type, with values <code>YES</code> for true and <code>NO</code> for false. Objective-C also adds several special types of pointers; for pointers to objects (values of type <code>id</code>), the <code>nil</code> pointer is false, everything else is true; for pointers to classes (values of type <code>Class</code>), the <code>Nil</code> pointer is false, everything else is true.
 
=={{header|OCaml}}==
Line 1,688 ⟶ 1,685:
 
As a special case, literal <tt>1</tt>s and <tt>0</tt>s will never cause a "Useless use of a constant in void context" warning. Another special case worth pointing out here is that the string <tt>'0 but true'</tt> won't provoke a warning if it's used as a number.
 
=={{header|Perl 6}}==
{{works with|Rakudo|2015.12}}
 
Perl 6 provides an enumeration <code>Bool</code> with two values, <code>True</code> and <code>False</code>. Values of enumerations can be used as ordinary values or as mixins:
 
<lang perl6>my Bool $crashed = False;
my $val = 0 but True;</lang>
 
For a discussion of Boolean context (i.e. how Perl decides whether something is true or false), see [http://perlcabal.org/syn/S02.html#Context Synopsis 2].
 
=={{header|Phix}}==
Line 1,759 ⟶ 1,746:
=={{header|Pony}}==
Boolean values are <code>true</code> and <code>false</code>. Conditions must have type Bool, i.e. they are always true or false.
 
=={{header|PostScript}}==
 
Predefined constants are:
<lang postscript>true
false</lang>
 
=={{header|PowerBASIC}}==
Line 1,769 ⟶ 1,762:
x = ISFALSE(1 = 1) ' returns 0
x = ISFALSE(1 = 0) ' returns -1</lang>
 
=={{header|PostScript}}==
 
Predefined constants are:
<lang postscript>true
false</lang>
 
=={{header|PowerShell}}==
Line 1,857 ⟶ 1,844:
 
... evaluates to <tt>'pear</tt>, because <tt>'bloggle</tt> is not false.
 
=={{header|Raku}}==
(formerly Perl 6)
{{works with|Rakudo|2015.12}}
 
Perl 6 provides an enumeration <code>Bool</code> with two values, <code>True</code> and <code>False</code>. Values of enumerations can be used as ordinary values or as mixins:
 
<lang perl6>my Bool $crashed = False;
my $val = 0 but True;</lang>
 
For a discussion of Boolean context (i.e. how Perl decides whether something is true or false), see [http://perlcabal.org/syn/S02.html#Context Synopsis 2].
 
=={{header|Raven}}==
Line 1,989 ⟶ 1,987:
=={{header|Self}}==
 
Self has two objects, ''true'' and ''false''.
 
=={{header|SenseTalk}}==
True, Yes, and On are true; False, No, Off and Empty (an empty string) are false.
Line 2,157 ⟶ 2,156:
True False True False
</pre>
 
=={{header|Visual Basic}}==
 
VB has the <code>Boolean</code> data type and the constants <code>True</code> and <code>False</code>, in addition to what's listed under [[#BASIC|BASIC]], above. When used outside of a boolean context, <code>True</code> and <code>False</code> return values depending on their context -- <code>-1</code> and <code>0</code> in a numeric context, <code>"True"</code> and <code>"False"</code> if used as strings.
<br>When converting an integer to a boolean, <code>0</code> is <code>False</code> and anything not equal to <code>0</code> is
 
<lang vb>Dim x As Boolean
x = IIf(Int(Rnd * 2), True, False)
MsgBox x</lang>
 
=={{header|Vim Script}}==
Line 2,176 ⟶ 2,166:
echo "false"
endif</lang>
 
=={{header|Visual Basic}}==
 
VB has the <code>Boolean</code> data type and the constants <code>True</code> and <code>False</code>, in addition to what's listed under [[#BASIC|BASIC]], above. When used outside of a boolean context, <code>True</code> and <code>False</code> return values depending on their context -- <code>-1</code> and <code>0</code> in a numeric context, <code>"True"</code> and <code>"False"</code> if used as strings.
<br>When converting an integer to a boolean, <code>0</code> is <code>False</code> and anything not equal to <code>0</code> is
 
<lang vb>Dim x As Boolean
x = IIf(Int(Rnd * 2), True, False)
MsgBox x</lang>
 
=={{header|WDTE}}==
10,351

edits