Boolean data types, by Zman


posted by davidw
Mon, Jul 21 2008

Downloads: 259
File size: 1kB
Views: 408
Boolean data types, by Zman
Filed under:
This program offers a brief explanation of boolean data types and sows. There are 2 'flavors' of booleans:

Bitwise * * * - Each binary digit in a number is operated on. Phrogram does not use bitwise operators.
Logical * * * - The operators on each side are assumed To be boolen True Or False. Then its treated as if its just one 'bit'

In languages like C++ & C#, these two boolean flavors are distinguished by the Operator, so &, | are bitwise and &&, || are logical [And, - vs. - And Or respectively]

Bitwise booleans are harder to use becuase they involve fancier math or lots of shifting and masking to expose each bit and do the operators. Logical booleans are easier becuase we give you And And Or already and you can implement Xor in terms of those.

This program demonstrates how this works. The "Xor1" naming is used because Phrogram won't let you call a function Xor, because it is a reserved, but unimplemented keyword.