Boolean values: Difference between revisions
Content added Content deleted
(shorten Pascal, by _grouping_ definitions into the norms that originally introduced certain types) |
|||
Line 105:
=={{header|ALGOL W}}==
The boolean type is called logical in Algol W - the values are represented by the keywords true and false. Numbers, strings etc. cannot be used where logical values are required.
=={{header|APL}}==
0 and 1 are used for boolean types in APL (as in J below).
Line 541 ⟶ 542:
=={{header|Delphi}}==
In addition to the types defined by [[#Object Pascal|Object Pascal]], Delphi defines the type <code>Bool</code>.
=={{header|Déjà Vu}}==
Line 551 ⟶ 549:
=={{header|DWScript}}==
The standard <code>Boolean</code> type has two values: <code>True</code> and <code>False</code>, with <code>Ord(False) = 0</code> and <code>Ord(True) = 1</code>.
Line 808 ⟶ 805:
-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,227:
not false;
/* true */</lang>
=={{header|Metafont}}==
Metafont has the type <tt>boolean</tt>; a boolean variable can be <tt>true</tt> or <tt>false</tt>.
Line 1,444 ⟶ 1,445:
=={{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}}==
In addition to the <code>Boolean</code> type defined by standard [[#Pascal|Pascal]], object Pascal defines the types <code>byteBool</code>, <code>wordBool</code> and <code>longBool</code>, having a <code>sizeOf</code> one, two, or four bytes respectively.
They were introduced primarily to ease interfacing with code written in other languages, such as [[#C|C]].
These types only have <code>ord(false)</code> defined as zero, and ''any'' other ordinal value represents <code>true</code>.
Nonetheless, <code>Boolean</code> is ''the'' preferred type.
''See also [[#Delphi|Delphi]] and [[#Free Pascal|Free Pascal]]''
=={{header|OCaml}}==
Line 1,493 ⟶ 1,503:
=={{header|Pascal}}==
Pascal
<code>false</code> and <code>true</code>.
It is guaranteed that <code>ord(false)</code> is <code>0</code> and <code>ord(false)</code> is <code>1</code>.
There is no automatic conversion from integer values to Boolean values, as it is prevalent in many other languages.
Instead, one has to write a Boolean expression, for example <code>myInteger <> 0</code> in order to get an assignment-compatible type.
''See also [[#Delphi|Delphi]], [[#Free Pascal|Free Pascal]], and [[#Object Pascal|Object Pascal]]''
=={{header|Perl}}==
Line 1,883 ⟶ 1,872:
{{out}}
<pre>false</pre>
=={{header|Simula}}==
Simula has <tt>true</tt> and <tt>false</tt> keywords, representing the only values of type <tt>boolean</tt>. There are no automatic conversions from any other types into <tt>boolean</tt>, and it is a compile-time error to use any type other than <tt>boolean</tt> in a place that expects a <tt>boolean</tt> (e.g. if-statement condition, while-statement condition, operand of a logical operator, etc.).
Line 1,953 ⟶ 1,943:
0 OK, 0:52</pre>
=={{header|UNIX Shell}}==
Line 1,995 ⟶ 1,986:
set bool (not (= 2 2))
</lang>
=={{header|VBA}}==
VBA has a boolean type. As an integer False is 0 and anything else is True. However True converts to -1. Booleans are False by default.
|