I will start the discussion on "how to represent values inside a computer program with:
|
because it is easy and intuitive
These are all the possible Boolean values are:
true
false
|
|
Python program that illustrates the encoding method:
if 0:
print("0: true")
else:
print("0: false") // <---- does this because 00000000 (=0) == false
if 1:
print("1: true") // <---- does this because 00000001 (=1) == true
else:
print("1: false")
if 4:
print("4: true") // <---- does this because 00000100 (=4) == true
else:
print("4: false")
|
DEMO: python3 /home/cs255001/demo/data-type/boolean.py