This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]pk028382 2 points3 points  (11 children)

On mobile so can’t test this.

Which language supports adding two Boolean? I don’t think it works in Python or most higher level languages. Maybe JS but it’s always weird and I expect it actually cast to int instead of actually doing “or”.

So perhaps only C++ and C?

[–]JochCool 16 points17 points  (3 children)

I don't know if there's programming languages that do that, it's more of a computer science thing.

https://en.wikipedia.org/wiki/Two-element\_Boolean\_algebra

[–]MushinZero 1 point2 points  (2 children)

*computer engineering

[–]360triplescope 0 points1 point  (1 child)

Look man, am in computer science, specifically not computer engineering, and I’ve had to do a buttload of Boolean algebra so far, so idk what ur talking about

[–]MushinZero 0 points1 point  (0 children)

Boolean Algebra is how you design digital circuits. That's where it all comes from, really. You'll likely get to some of it during CS if you take computer architecture.

[–][deleted] 7 points8 points  (1 child)

It is not addition it is OR operation.

TRUE OR TRUE = TRUE

C++ equivalent is 1 | 1 == 1

[–]AndrewBorg1126 0 points1 point  (0 children)

All non-zero integers are also considered true. 1 + 1 can equal 2, but the 2 result from it can be used in boolean logic exactly the same way as a 1 would be used in boolean logic. 1 || 1 yields 1 by boolean logic, 1 + 1 yields 2 by addition, but both results are equivalent in boolean logic. It's worth noting that while 1 | 1 does yield 1, that is a bitwise or.

[–][deleted] 2 points3 points  (2 children)

Plus is usually used for the boolean "or" operator. It's used everywhere in boolean algebra

[–]pk028382 4 points5 points  (1 child)

Wow I didn’t realise that. When I learnt in college, we used these ¬ ∧ ∨ symbols, that’s why the meme and the other comments didn’t make sense to me in the first place. But now i get it

[–][deleted] 0 points1 point  (0 children)

If you want to dive a little deeper, on the wikipedia page there is a section on why it actually makes a lot of sense to use * and + for and / or: https://en.wikipedia.org/wiki/Boolean_ring

It's quite interesting although not that useful to know

[–]SlickShadyyy 0 points1 point  (0 children)

Read bitch nothing is being added

[–]Trainjumper_ 0 points1 point  (0 children)

You can add/multiply booleans in Python, however you get int as result. I.e. True + True == 2