why do we even compare things using the boolen type | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

why do we even compare things using the boolen type

true or false

14th Apr 2019, 8:15 PM
clovert
clovert - avatar
2 Answers
+ 6
Sometimes you just have to distinguish two states: true or false, 1 or 0, on or off, execution or not. In such a case, why should you offer countless choices when it comes down to checking whether something is being done or not?
14th Apr 2019, 8:47 PM
Crash
Crash - avatar
+ 1
Programming is operated in binary logics, the comparison logic has to be in boolean form, true or false, 2 conditions. Even for multiple choice, you cannot compare all the multiple choices at once, they have to be spitted into multiple binary conditions. For example: if(select==choice1) select1(); // boolean for choice 1 else if(select==choice2) select2();// boolean for choice 2 else if(select==choice3) select3();// boolean for choice 3 else selectLast();// boolean for last choice
15th Apr 2019, 5:51 AM
Calviղ
Calviղ - avatar