Boolean Datatypes

Blitz3D Forums/Blitz3D Beginners Area/Boolean Datatypes

Tau_Aquilae(Posted 2012) [#1]
Correct me if I'm wrong in my understanding of how boolean works in blitz

Blitz 3D doesn't necessarily support boolean datatypes despite having boolean keywords "true" and "false" (I.E you can't store these in a boolean datatype like in Java for example)

Instead "True" is an integer 1 or float 1.0 and "False" is integer 0 or float 0.0

or am I completley missing the mark?


Yasha(Posted 2012) [#2]
Nope, no Booleans. "True" and "False" are just keyword-recognised constants for 1 and 0 respectively.

Further:

The conditional ("If") statement considers zero to be false, and any non-zero integer value to be true. Floats and strings are implicitly cast to int, in line with the usual implicit casting rules (better guideline: never use a float or string as a boolean). Unlike in C and C-like languages, pointers to objects of custom type ("Local myFoo.Foo" etc.) cannot be used as truth values (nor can they be used as the argument to a Select structure, oddly, even though that's not boolean). Comparison operators (=, <>, <, ...) return an integer 1 or 0.


Tau_Aquilae(Posted 2012) [#3]
Ok that makes sense thanks!