Why relational operators and not simply true / false?


#1

Why should we use relational operators with numbers where we could simply give it a true or false value?
Example:
w/ operators >>> !( 1 < 8 && (5 > 2 || 3 < 5)); <<<<

w/ true or false >>> !true && true || true;

What are the differences?
Could you give me an example where the code w/ operators cannot be replaced by a true or false value?


#2

Those numbers are arbitrary. Imagine they were variables instead.
if(price > income/10 || storeNextDoorPrice < thisStore)

We don’t want to sit there and think out long boolean expressions, or do the math involved. So we tell the cpu to do it.


#3

Right, that makes sense. Thank you!


#4

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.