Logic operators

Just some confusion I'd like to clear up.

If you take an AND and NOT it, you have a NAND: !(a&&b)

what is Nand saying? It's not boxes and chocolates? So, if boxes and chocolates come back as true, it's false and vice versa?

If you take an OR and NOT it, you have a NOR: !(a||b)

What is the Nor saying? It's neither beans or apples? So if beans or apples comes back as true, it's false?


All these things (AND, OR, NOT, NAND and OR) can be built in electronic parts and are known as 'gates'. Gates are the building blocks for the CPU in a computer.

How can AND, OR, NOT, NAND, and OR be built in electronic parts? Can someone give me a brief explanation.
closed account (48T7M4Gy)
https://en.m.wikipedia.org/wiki/AND_gate
Thanks for the reply! That didn't quite answer my questions. <3

Did I not word it clearly enough?
Did I not word it clearly enough?

It's clear enough it doesn't have anything to do with C++, which is what is on-topic in this forum.
Yes it does. These are C++ logical operators. It has everything to do with C++?

The only thing unrelated to C++ itself is me asking about the electronic parts, but since this site is likely filled with people that work with computers, I'd figured it would be appropriate to ask.

Perhaps asking my professor about this one may benefit me more, haha.



Last edited on
Yes it does. These are C++ logical operators. It has everything to do with C++?

Because something in another domain has an analog in C++ doesn't mean discussing it in the other domain is discussing C++.

Perhaps the stuff concerning NAND and NOR (which C++ has no concept of) were meant to be questions concerning the corresponding C++ logic expressions, but these terms don't really make sense outside of electronics. You're invited to construct logic tables for those expressions if you were asking about what they mean in terms of C++ logic operators (or search for them yourself,) instead of asking someone to make or search for them for you.

The other is also a simple search away. Feel free to do some research for yourself.
As they've said, logic gates (NAND, NOR, etc) don't really have too much place in programming. Sure, the construct:

!(a && b) == NAND
!(a || b) == NOR

And is routinely utilized, logic gates for electronics doesn't really apply so well here. As far as what they represent, they represent exactly what you think - the inverse of the original. Or to put it another way, whatever the logic operation would evaluate to WITHOUT the inverse operator (!) is the OPPOSITE what it would evaluate to WITH it.

if a == 1 and b == 1, !(a && B) == 0, because (a && b) == true, and !true == false.

If I recall correctly (mind you it has been nearly a decade) integrated circuits and combinations of them either have them built in naturally, or can be combined to create them. Of course, if you're talking about building them from scratch, I believe combinations of transistors and possibly including diodes can achieve the desired results. Again, it has been a long time, but you should start there. PICs can do this far easier, though that comes with the caveat that the hardware for them is typically quite expensive.
"Because something in another domain has an analog in C++ doesn't mean discussing it in the other domain is discussing C++.

Perhaps the stuff concerning NAND and NOR (which C++ has no concept of) were meant to be questions concerning the corresponding C++ logic expressions, but these terms don't really make sense outside of electronics. You're invited to construct logic tables for those expressions if you were asking about what they mean in terms of C++ logic operators (or search for them yourself,) instead of asking someone to make or search for them for you.

The other is also a simple search away. Feel free to do some research for yourself."

I'm not exactly sure what you're trying to say (your wording is throwing me off a bit), but we use NAND and NOR in my class projects all the time. It was explicitly taught in the book this was a C++ concept with the exception of a few other programs. Perhaps I'm confusing something? By NAND I mean !(a && b) and by NOR I mean !(a || b). I also never asked anyone to make or search them for me.

I said I don't understand what they were saying, and provided questions to what I didn't understand that couldn't be clearly looked up online.



Last edited on
Yeah, Yawzheek. I was talking about the constructs, haha.

You answered my questions before my professor did, thank you! I believe the makes sense now.
Last edited on
Topic archived. No new replies allowed.