Boolean values: Difference between revisions

Content added Content deleted
No edit summary
Line 1,113: Line 1,113:


=={{header|FutureBasic}}==
=={{header|FutureBasic}}==
FB recognizes two types for boolean truth values: BOOL and boolean. There is a subtle difference between the two. A BOOL will accept without complaint two values, the macros YES, and NO, or the equivalent native FB constants, _true, and _false. However, although a BOOL can be assigned other values, it will throw a clang (FB"s native compiler) warning as with this example:
FB recognizes two types for boolean truth values: BOOL and boolean. There is a subtle difference between the two. A BOOL will accept without complaint the macros YES, and NO, the equivalent native FB constants, _true, and _false, and, of course, 0 and 1. However, although a BOOL can be assigned other values, it will throw a clang (FB"s native compiler) warning as with this example:
<syntaxhighlight lang="futurebasic">
<syntaxhighlight lang="futurebasic">
window 1
window 1
Line 1,125: Line 1,125:
implicit conversion from constant value -1 to 'BOOL'; the only well defined values for 'BOOL' are YES and NO [-Wobjc-bool-constant-conversion]
implicit conversion from constant value -1 to 'BOOL'; the only well defined values for 'BOOL' are YES and NO [-Wobjc-bool-constant-conversion]
</syntaxhighlight>
</syntaxhighlight>
On the other hand, a Boolean can be assigned not only YES, NO, _true, or _false, but also any integer value, such as the common -1, an compile without complaint.
On the other hand, a Boolean can be assigned not only YES, NO, _true, or _false, and 0 or 1, but also other values, such as the common -1, and compile without complaint.


Since FB can also work with objects, native BOOLs and booleans need to be converted to objects as demonstrated in the code below.
Since FB can also work with objects, native BOOLs and booleans need to be converted to objects as demonstrated in the code below.
Line 1,190: Line 1,190:
booleanObject variable reassigned as N0 == 0
booleanObject variable reassigned as N0 == 0
</pre>
</pre>




=={{header|Gambas}}==
=={{header|Gambas}}==