<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>binary logic Archives - NeuralLantern.com</title>
	<atom:link href="https://www.NeuralLantern.com/tag/binary-logic/feed/" rel="self" type="application/rss+xml" />
	<link>https://www.NeuralLantern.com/tag/binary-logic/</link>
	<description></description>
	<lastBuildDate>Sun, 06 Jul 2025 13:41:23 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.9.4</generator>

<image>
	<url>https://www.NeuralLantern.com/wp-content/uploads/2025/04/cropped-2025-04-04-Lantern-03-32x32.png</url>
	<title>binary logic Archives - NeuralLantern.com</title>
	<link>https://www.NeuralLantern.com/tag/binary-logic/</link>
	<width>32</width>
	<height>32</height>
</image> 
	<item>
		<title>Logic Gates Crash Course: Learn AND, OR, XOR, NOT &#038; Build Circuits</title>
		<link>https://www.NeuralLantern.com/logic-gates-crash-course-learn-and-or-xor-not-build-circuits/</link>
					<comments>https://www.NeuralLantern.com/logic-gates-crash-course-learn-and-or-xor-not-build-circuits/#respond</comments>
		
		<dc:creator><![CDATA[mike]]></dc:creator>
		<pubDate>Sun, 06 Jul 2025 13:41:22 +0000</pubDate>
				<category><![CDATA[Computer Science]]></category>
		<category><![CDATA[AND gate]]></category>
		<category><![CDATA[beginner electronics]]></category>
		<category><![CDATA[binary logic]]></category>
		<category><![CDATA[circuit design]]></category>
		<category><![CDATA[computer engineering]]></category>
		<category><![CDATA[computer science basics]]></category>
		<category><![CDATA[digital electronics]]></category>
		<category><![CDATA[digital logic]]></category>
		<category><![CDATA[logic circuits]]></category>
		<category><![CDATA[logic gates]]></category>
		<category><![CDATA[NOT gate]]></category>
		<category><![CDATA[OR gate]]></category>
		<category><![CDATA[tech tutorials]]></category>
		<category><![CDATA[truth tables]]></category>
		<category><![CDATA[XOR gate]]></category>
		<guid isPermaLink="false">https://www.NeuralLantern.com/?p=176</guid>

					<description><![CDATA[<p>Learn logic gates (AND, OR, XOR, NOT) with diagrams &#038; circuits. Fun, clear intro to digital logic for beginners.</p>
<p>The post <a href="https://www.NeuralLantern.com/logic-gates-crash-course-learn-and-or-xor-not-build-circuits/">Logic Gates Crash Course: Learn AND, OR, XOR, NOT &amp; Build Circuits</a> appeared first on <a href="https://www.NeuralLantern.com">NeuralLantern.com</a>.</p>
]]></description>
										<content:encoded><![CDATA[
<figure class="wp-block-embed is-type-video is-provider-youtube wp-block-embed-youtube wp-embed-aspect-16-9 wp-has-aspect-ratio"><div class="wp-block-embed__wrapper">
<iframe title="Logic Gates Crash Course: Learn AND, OR, XOR, NOT &amp; Build Circuits" width="1380" height="776" src="https://www.youtube.com/embed/ah5DzK_VJr0?feature=oembed" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share" referrerpolicy="strict-origin-when-cross-origin" allowfullscreen></iframe>
</div></figure>



<p>Hey there! In this video, I’m diving into the world of logic gates &#8211; AND, OR, XOR, and NOT. We’ll break down how each gate works, draw them in ANSI style, and rig up a circuit to see how they turn inputs into logical outputs. I’ll walk you through truth tables and show you how to chain gates for cool results, all while keeping it real and relatable. Whether you’re new to digital logic or just want a refresher, this is for you. Got questions? Drop a comment! Subscribe to join the crew, and scan the QR code to check out my site for more tutorials. Let’s geek out together!</p>



<p>Introduction to Logic Gates 00:00:00<br>Overview of AND Gate 00:00:47<br>Overview of OR Gate 00:01:07<br>Overview of XOR Gate 00:01:24<br>Overview of NOT Gate 00:01:49<br>Drawing AND Gate 00:02:14<br>Drawing OR Gate 00:03:07<br>Drawing XOR Gate 00:04:12<br>Drawing NOT Gate 00:05:31<br>Building a Circuit 00:06:04<br>Combining Gates 00:07:21<br>Testing with All Zeros 00:09:56<br>Testing with All Ones 00:11:23<br>Testing with Random Inputs 00:12:32<br>Introduction to Truth Tables 00:15:00<br>Creating Truth Tables 00:16:03<br>Analyzing Circuit with Truth Tables 00:18:50<br>Hierarchical Truth Table Approach 00:20:04<br>Final Circuit Analysis 00:26:36<br>Conclusion and Call to Action 00:29:15</p>



<p>Thanks for watching!</p>



<p>Find us on other social media here:</p>



<ul class="wp-block-list">
<li>https://www.NeuralLantern.com/social</li>
</ul>



<p>Please help support us!</p>



<ul class="wp-block-list">
<li>Subscribing + Sharing on Social Media</li>



<li>Leaving a comment or suggestion</li>



<li>Subscribing to our Blog</li>



<li>Watching the main &#8220;pinned&#8221; video of this channel for offers and extras</li>
</ul>



<p>Okay, hey everybody! In this video I&#8217;m going to talk about logic gates. I&#8217;m going to show you</p>



<p>AND, OR, XOR, and NOT. We&#8217;re going to draw them in a diagram style and we&#8217;re going to rig up a</p>



<p>bunch against each other and see if we can figure out how they would process some input data into</p>



<p>you know some logical output.</p>



<p>Okay so for starters let&#8217;s just go over what the gates look like. If you don&#8217;t know how these gates</p>



<p>don&#8217;t know how these gates work check my previous videos because I&#8217;ve explained them there. Here I&#8217;m</p>



<p>just going to sort of try to draw them and make a little big a little circuit area that we can play</p>



<p>with. Okay so AND. Okay you know what you want me to I&#8217;ll just do a quick recap. The AND gate just</p>



<p>means that both bits have to be a 1 in order for a 1 2 output so if we do a 0 and a 0 and a 1 and</p>



<p>sorry one and a zero and a one and a one then only this one is going to end up being a one</p>



<p>everything else is going to be a zero for the logical or it&#8217;s going to be if we do zero zero</p>



<p>zero one one zero and one one and if this is too fast and confusing for you see my other videos</p>



<p>but basically it&#8217;s going to be a one for those three because if either of those bits are a one</p>



<p>then the output is going to be a one and the only place it&#8217;ll be a zero is when both of the bits are</p>



<p>Let&#8217;s look at XOR. So XOR is</p>



<p>Basically and it&#8217;s an OR except this one position right here where both bits are a one that would end up being a zero</p>



<p>So for XOR 0 0 0 1 1 0 1 1</p>



<p>It&#8217;s going to be a 0 and</p>



<p>Then a 1 and then a 1 and then a 0 so it&#8217;s just a little bit different from OR and then not just inverts the bits</p>



<p>so</p>



<p>bit at a time and it&#8217;s just a zero becomes a one and a one becomes a zero and that&#8217;s pretty much it</p>



<p>okay so maybe I should put not right here just to just to emphasize that I&#8217;m talking about not</p>



<p>okay I&#8217;m definitely not not talking about not sorry so let&#8217;s do uh let&#8217;s draw a logical or a</p>



<p>bitwise and gate it&#8217;s basically just kind of like this and then there&#8217;s a little flat ridge at the</p>



<p>end of it and it takes two inputs there are many different styles to draw these kinds of gates but</p>



<p>i&#8217;m going to use the ansi style i think for the most part so just keep in mind you know you can</p>



<p>draw these in many different ways it&#8217;s going to take two inputs imagine this is a little circuit</p>



<p>right here and it&#8217;s going to give you one output so if you imagine what we talked about before</p>



<p>we could send it two different bits and it will produce the output for us so if we give it a zero</p>



<p>for us. If we give it a 0 and a 1, it&#8217;s still going to output a 0. If we give it a 1 and a 0,</p>



<p>still a 0. If we give it a 1 and a 1, then finally it&#8217;ll actually give us a 1.</p>



<p>Okay, so that&#8217;s just the way that gate looks. And now I&#8217;m going to draw the next one.</p>



<p>Let&#8217;s draw the OR. So maybe I&#8217;ll put OR here. Whoops. Oh, I got to do that. OR. So the OR gate</p>



<p>kind of looks like the AND gate at least in the style that I&#8217;m drawing except the</p>



<p>the flat ridges is more curved like this so you know an AND gate I&#8217;ll draw it in</p>



<p>red just to remind you that this is not what we&#8217;re doing right now it&#8217;s you know</p>



<p>flat right where&#8217;s the OR gate it has a curve it&#8217;s like a crescent moon kind of</p>



<p>it still takes two inputs so I&#8217;m gonna do an input here and an input here and</p>



<p>it still has one output and so if we&#8217;re just gonna give it a zero and a zero it&#8217;s</p>



<p>give it a zero and a zero it&#8217;s going to output zero for us if we give it a zero</p>



<p>and a one it&#8217;s going to output a one if we give it a one and a zero it&#8217;ll still</p>



<p>output a one if we give it a one and a one it&#8217;ll still output a one okay that</p>



<p>was pretty easy let&#8217;s look at exclusive or so XOR XOR the XOR gate looks like</p>



<p>like the ore gate so i&#8217;m going to start by trying to draw an ore gate as best i can</p>



<p>which is not good oh god let me start over on that one let me try one more time and then i&#8217;ll just</p>



<p>give up okay do this and then i&#8217;ll say okay that was good enough and then it has another line right</p>



<p>here the line is supposed to be parallel to the uh the crescent moon you know the curved side but</p>



<p>and that way it sort of looks like the inputs are passing through</p>



<p>like the first line before they touch the actual ridge.</p>



<p>So that&#8217;s an exclusive or it also outputs one bit.</p>



<p>So just practicing, we&#8217;ll give it two zeros.</p>



<p>It&#8217;s going to output a zero because there&#8217;s no or involved in two zeros</p>



<p>or I guess there&#8217;s no orness to the two zeros.</p>



<p>If we give it a zero and a one, then that&#8217;s going to output a one</p>



<p>one input is a one if we give it a one and a zero same thing looks good because</p>



<p>one input was a one but then once we get to two inputs then it&#8217;s going to output</p>



<p>a zero because the exclusive or demands that only one of the bits is a one and</p>



<p>actually exactly one of the bits is a one to produce a one okay so then the</p>



<p>next thing that I can show you is a knot gate it&#8217;s sort of like a little triangle</p>



<p>are different drawing styles it takes only one input and then there&#8217;s like a little circle up</p>



<p>here on top and then it outputs at the top and so if we give it a zero it&#8217;s going to output a one</p>



<p>i guess i could draw it a second time since there&#8217;s only you know two things we can we can input to it</p>



<p>it&#8217;s going to give us a zero if we inputted a one into it so it just reverts it&#8217;s an inverter</p>



<p>helps you understand the basics of these types of gates. Now I&#8217;m going to try to make a bunch of</p>



<p>them see if I can come up with something interesting on the fly. I had problems with</p>



<p>the drawing system on my other computer so I didn&#8217;t really prepare an example. Hopefully this</p>



<p>is good you never know. I&#8217;m just going to draw an AND gate here and I&#8217;ll say that it takes two</p>



<p>inputs because that&#8217;s what it does and then right next to it maybe I&#8217;ll do an exclusive OR so I&#8217;ll</p>



<p>like an OR gate here, and then I&#8217;ll do the exclusive OR part of it, and I&#8217;ll give it</p>



<p>two inputs because that&#8217;s what they take.</p>



<p>And then next to that, maybe I&#8217;ll just do a regular OR.</p>



<p>We&#8217;ll say OR, just like that.</p>



<p>Oh, that&#8217;s awful.</p>



<p>Try one more time.</p>



<p>Just do this, and then say this.</p>



<p>Okay, that&#8217;s acceptable, sort of.</p>



<p>We&#8217;ll do two more inputs there.</p>



<p>And what else can I do?</p>



<p>What else can I do?</p>



<p>Should I do another exclusive or or an and?</p>



<p>What do you think?</p>



<p>Vote.</p>



<p>Just kidding.</p>



<p>I&#8217;m going to do an and right here.</p>



<p>So I&#8217;m kind of repeating one of the gates.</p>



<p>Let&#8217;s see.</p>



<p>And or X or not.</p>



<p>Yeah, that&#8217;s all I wanted to talk about.</p>



<p>Okay, so now we can combine them because remember these have an output.</p>



<p>But if we sort of use the outputs of two of the gates as input for another gate,</p>



<p>then we can you can we can sort of like chain uh our circuits to make something a little bit more</p>



<p>interesting so maybe here i&#8217;ll do an and i&#8217;ll say this is an and gate oh god that&#8217;s awful</p>



<p>one more time okay my text-to-speech engine who i&#8217;ve given the personality of mary poppins</p>



<p>is telling me that a door is open so i&#8217;ve got to close the door after this video anyway</p>



<p>video anyway um yeah I have like an LLM server uh in the other room and so now my home assistant</p>



<p>is a little bit smarter and sometimes she messes with me that&#8217;s a story for another video</p>



<p>so I&#8217;m combining the output of both of those gates and sticking them into an and</p>



<p>and then I can do the same thing here I think I drew those I think I drew it like way too high</p>



<p>I&#8217;m gonna run out of room let me try one more time put that there we&#8217;ll do an and gate</p>



<p>gate like that and then I&#8217;ll just maybe curve the wires so it seems like uh it makes more sense okay</p>



<p>and then maybe over here I&#8217;ll do uh I don&#8217;t know maybe this should be an or I&#8217;ll do an or gate</p>



<p>like that and then the inputs from the other ones go into the or gate</p>



<p>then these two can combine to one more so maybe I&#8217;ll do exclusive or</p>



<p>or I guess I&#8217;ll just put an or gate here and then I will that&#8217;s not that&#8217;s not</p>



<p>curvy enough is it I like my Alex might I like my XOR gates nice and curvy so</p>



<p>we&#8217;ll do this and then I&#8217;ll put another line under it and then we&#8217;ll connect</p>



<p>these two so we&#8217;ll do this okay so then finally we have like one bit that&#8217;s</p>



<p>one bit that&#8217;s going to come out at the top let&#8217;s use the knot gate might as well so i&#8217;m going to</p>



<p>connect this to a knot gate and put a little circle on top of it and then it will give us our</p>



<p>final output and maybe i&#8217;ll stick it here in green or something like that okay so there&#8217;s lots of</p>



<p>different uh input output combinations we could use uh let&#8217;s see for every input we have that&#8217;s</p>



<p>one bit so one two three four five six seven eight that&#8217;s eight bits that means i could draw out</p>



<p>256 possible input combinations, which I&#8217;m definitely not going to do in this video.</p>



<p>But let&#8217;s just do some random stuff.</p>



<p>Let&#8217;s start off with zeros just for fun.</p>



<p>So we&#8217;ll do a bunch of zeros here.</p>



<p>So if you sort of look at this diagram, we go, all right, what was that?</p>



<p>This and here, there&#8217;s two zeros.</p>



<p>It&#8217;s going to produce a one.</p>



<p>So I&#8217;m just going to put a one right here to remind me that a one is going to be the</p>



<p>output of that gate.</p>



<p>the OR gate here is going to also output a what am I doing why did I put a one a zero because zero</p>



<p>and zero is zero and then zero or zero is also zero so this is going to output a zero and then</p>



<p>this exclusive OR is also going to output a zero and then the end is zero so I just have zeros at</p>



<p>the next level then we look at the inputs here to this and that&#8217;s obviously going to be zero and</p>



<p>then we look at the OR here that&#8217;s obviously going to be zero and then those two go into the gate</p>



<p>that&#8217;s a little bit higher and it&#8217;s going to output a zero because exclusive</p>



<p>or needs at least, you know, it needs exactly one, uh, one.</p>



<p>So it kind of feels like it&#8217;s going to be a zero for the output, right?</p>



<p>Uh, you&#8217;d be wrong if you thought that because the knot is going to invert it.</p>



<p>The knot is going to take that zero and flip it to a one.</p>



<p>So if we do all zeros, the answer is actually going to be a one.</p>



<p>Okay.</p>



<p>Let&#8217;s reset this and try again.</p>



<p>So I&#8217;m going to just get rid of these greens here.</p>



<p>and then I&#8217;m going to do, maybe I should write the inputs in red so they&#8217;re more fun,</p>



<p>so they don&#8217;t feel like they&#8217;re blending too much in with the actual diagram.</p>



<p>Okay, so now I&#8217;m going to, let&#8217;s try all ones. Let&#8217;s see what happens if we do all ones.</p>



<p>So I&#8217;m going to do ones on every input. One, one, one, one, one, one, one. And so</p>



<p>if we look at this AND gate, it&#8217;s going to output a one because, well, a one and one is a one.</p>



<p>one is a one the or gate same thing because a one or one is a one and then do the same thing down</p>



<p>here for this and and then the exclusive or that&#8217;s going to be a zero because it wants exactly one</p>



<p>bit to be a one not both so it&#8217;s a little bit more interesting and then we go up one level this and</p>



<p>gate is going to output a zero because it wanted both of those uh inputs to be a one for it to</p>



<p>output a one and then for the or it&#8217;s also going to output a well it&#8217;s going to output a one again</p>



<p>both of those are ones and then if we look at the exclusive or oh that&#8217;s going to output a one this</p>



<p>time because exactly one of the inputs is a one then the not is going to invert it so the final</p>



<p>answer is going to be zero for this whole giant thing i want to say make sense and wait for</p>



<p>questions but i guess i can&#8217;t so let&#8217;s try another example i&#8217;m going to do maybe two examples with</p>



<p>totally random numbers and then i&#8217;m going to show you how to write a truth table that might help you</p>



<p>might help you work this out on paper or like a like a notepad if you don&#8217;t really want to draw</p>



<p>so let&#8217;s see um uh i guess i&#8217;m gonna like maybe take some of these and turn these into zeros</p>



<p>let&#8217;s see get rid of that make that a zero maybe like i don&#8217;t know i feel like i&#8217;m not random</p>



<p>enough okay one zero and then like a maybe like a zero here how about like a one there and a zero</p>



<p>How about like a one there and a zero there?</p>



<p>Just one, zero, one, zero, oh, one, oh, one.</p>



<p>That&#8217;s too much of a pattern.</p>



<p>Let me do, let me do a one, oh here, or a one and a one.</p>



<p>Okay.</p>



<p>That feels more random to me.</p>



<p>So looking at the AND gate, that&#8217;s going to output a zero.</p>



<p>The OR gate is going to output a one.</p>



<p>The exclusive OR is going to output a zero.</p>



<p>The AND is going to output a zero.</p>



<p>So we just got a one right there.</p>



<p>So this AND is going to output a zero again.</p>



<p>This OR is going to output a one.</p>



<p>And then the exclusive OR, it&#8217;s got enough to output a one.</p>



<p>it&#8217;s got enough to output a one so that&#8217;s nice and then its final output is going to be</p>



<p>a zero because we had to not that one nice okay let&#8217;s just i don&#8217;t know change a couple random</p>



<p>bits i&#8217;m going to change this well let me erase first and then i&#8217;m going to start changing random</p>



<p>bits i don&#8217;t even remember what that last bit was anymore i&#8217;m going to pretend it was a one</p>



<p>and then i&#8217;m going to change it to a zero and then i&#8217;m going to change this zero to a one</p>



<p>change this one to a zero and then I&#8217;ll change this this zero to a one not like exactly random</p>



<p>it&#8217;s human random sort of so let&#8217;s look at this the and is going to output a one and the exclusive</p>



<p>or is going to do a one and then the or is going to do a one and then the and is going to do zero</p>



<p>one and one zero okay I think I did it right so the or is going to do a one and then I think</p>



<p>what&#8217;s happening is I gotta adjust my penmanship style I still have to like lift up sooner so it</p>



<p>doesn&#8217;t change colors so then the end it&#8217;s going to output a one and then this exclusive or it&#8217;s</p>



<p>going to output a zero because it wants only one bit one input to be a one and then the not is</p>



<p>Okay, let&#8217;s look at the idea of using a truth table to make this a little bit easier to</p>



<p>solve if you&#8217;re just kind of doing this without drawing.</p>



<p>So I&#8217;m not going to clear this just yet.</p>



<p>I might have to clear it in a second.</p>



<p>The first thing that you should do when you&#8217;re making a truth table is, you know, I mean,</p>



<p>I guess you can style this however you want, but you kind of have to think of this hierarchically.</p>



<p>Like what&#8217;s the easiest thing to do?</p>



<p>You don&#8217;t want to start computing the thing at the very top because that depends on a</p>



<p>lot of other stuff that&#8217;s at the bottom.</p>



<p>So instead I&#8217;m going to look at the very bottom row of inputs because they&#8217;re the easiest to calculate.</p>



<p>So I&#8217;m going to do and, I&#8217;m going to say something and something.</p>



<p>I guess I&#8217;m just going to put and by itself.</p>



<p>Maybe I&#8217;ll put one for input.</p>



<p>So for the inputs, I&#8217;ll just do the bits here.</p>



<p>0 1 1 no okay let&#8217;s just use two inputs only because we&#8217;re looking at the lowest level here</p>



<p>yeah and we&#8217;ll make maybe like a separate row or separate table for that so we just have two</p>



<p>inputs per gate on the bottom row and so for the end it&#8217;s going to be a one right then for the 0 1</p>



<p>should just do this in numeric order. I&#8217;ll just do every possible combo because we don&#8217;t have that</p>



<p>many numbers. So we have four combos. This is like zero, one, two, three. So from zero to three or</p>



<p>four possible combos. And then the end is going to be a zero here and a zero there and a zero there.</p>



<p>So that&#8217;s a truth table that just handles that first gate. So then I&#8217;m just going to, you know,</p>



<p>write, I mean, you could make another truth table for this, but I&#8217;m going to try to write this in a</p>



<p>I&#8217;m going to try to write this in a more compact way.</p>



<p>I&#8217;m going to say the second column is the result of ending.</p>



<p>The next column is the result of oaring.</p>



<p>And then the last column is the result of,</p>



<p>maybe second to last is the result of an XOR.</p>



<p>And then maybe I&#8217;ll make another table for nodding.</p>



<p>So what is the result of an OR here?</p>



<p>It&#8217;s going to be a, whoops, a zero.</p>



<p>The OR here is going to be a one.</p>



<p>So when you start to make these tables,</p>



<p>it just makes it a little bit easier to work your way up because when it gets time to let&#8217;s say the</p>



<p>not you don&#8217;t have to compute all the other things because they&#8217;re already computed in the table so</p>



<p>we got the or which i should have probably done first because the second gate was an xor i should</p>



<p>have done that maybe third i don&#8217;t know i&#8217;m going to leave it as and and or right now and then we&#8217;re</p>



<p>going to do xor so xor is basically if exactly one bit is a one will output a one so that&#8217;s a one</p>



<p>so that&#8217;s a one there and then a one there and then a zero there okay so we&#8217;ve got the basics</p>



<p>and if you think about it that&#8217;s the whole bottom row right so if we&#8217;re just sort of looking at</p>



<p>let&#8217;s say the the third gate right here then uh we just have to look at input one one for the or</p>



<p>and then that&#8217;s this right here right there so that tells us what the answer would be truth table</p>



<p>for input zero one we just have to go all right zero one xor the output should be a one</p>



<p>and we can double check ourselves because it&#8217;s really really easy to make mistakes i&#8217;m sure</p>



<p>there&#8217;s a chance that i have or will make a mistake pretty soon</p>



<p>so we did and or an xor let&#8217;s do maybe just one for the knot just to remind ourselves of what it is</p>



<p>and i&#8217;ll just say not and so we can only do two different inputs on the uh on the knot so i&#8217;m</p>



<p>so I&#8217;m going to go maybe a zero and then a one right here and then the not is going to say we</p>



<p>have a one there and a zero there okay so now we can get a little bit more complicated</p>



<p>by combining these terms so for the input now we could do</p>



<p>we could do uh let&#8217;s say two gates at a time so we&#8217;ll do the input here and we&#8217;ll say the input</p>



<p>1, 0, 1.</p>



<p>And so when we not, when we not the, well, when we do an and for the 1, 1, we can end</p>



<p>up with a 1.</p>



<p>And then when we do an XOR on the 0, 1, then this is not the best truth table, to be honest.</p>



<p>I&#8217;m just trying to I&#8217;m just trying to do it the XOR is going to be a one so now we kind of have</p>



<p>the results written down here let&#8217;s do another little table and you know the way these tables</p>



<p>work is you kind of want to put every possible combination of inputs there but that alone is</p>



<p>going to be so many combinations I don&#8217;t want to write it all down and by the time we get to eight</p>



<p>bits it&#8217;s going to be like in the 200s so if we just look at the next pair of gates we&#8217;ll say</p>



<p>gates will say one one zero zero and the first thing is an or for the one one and</p>



<p>then the next thing is an and for the zero zero and so I can just write this</p>



<p>down and go all right the or is going to be a one and the end is going to be a</p>



<p>zero okay so then I can do another level I&#8217;ve pretty much just handled you know</p>



<p>the bottom row here and again each table is supposed to be filled out for every</p>



<p>combination of inputs but I can now just kind of move on to the next row I can say</p>



<p>what is the result of inputting a one and a one you could do that but it might be a little bit</p>



<p>better and closer to some other places that might want you to input this sort of thing</p>



<p>to write down what is the result of the or what is the what are the two gates that are giving you</p>



<p>Okay, so the first input on the very bottom left, that&#8217;s an and, right?</p>



<p>And then the next input on the bottom row is an XOR.</p>



<p>And if we&#8217;re trying to figure out, you know, how are we combining those?</p>



<p>We could say and XOR, or we can do, you know, two ampersands.</p>



<p>I guess I&#8217;m going to do and XOR, just to keep it in plain English as much as I possibly can.</p>



<p>So basically, this is going to have, you know, one result.</p>



<p>this is going to have, you know, one result, you know, one bit result and its input is going to be</p>



<p>a one, one, zero, one. And so maybe I should do another row here. We can say the end</p>



<p>for the end is going to, for one, one is going to be that. And the XOR is going to, well,</p>



<p>I already wrote that down in the table. Okay. I&#8217;m just going to, I&#8217;m just going to clean it up</p>



<p>because you know, it&#8217;s really good in these truth tables. If you write down all</p>



<p>truth tables if you write down all of the numbers, but I&#8217;m just going to do it this.</p>



<p>I&#8217;m just going to do it this.</p>



<p>Maybe we can visually see that there&#8217;s a one one going into the first end and then a zero</p>



<p>one going into the second gate, which is an XOR.</p>



<p>I think maybe that&#8217;s acceptable.</p>



<p>So the result of that, if we just sort of look up at this table here, we have, you know,</p>



<p>what is the end and what is the OR?</p>



<p>It&#8217;s a one and a one.</p>



<p>So if we end those two together, that should be a one.</p>



<p>that should be a one so that means if we end the and against an xor then that&#8217;s the result that we</p>



<p>get and then we&#8217;ll make another little table here for the next layer of inputs so i&#8217;ll just do this</p>



<p>and i&#8217;ll say</p>



<p>or and then the operator that combines them is an or and then on the right side it&#8217;s an and</p>



<p>The input to both of those is going to be a one, one, zero, zero.</p>



<p>And again, you should make another row for every possible combination of inputs.</p>



<p>That would be a really smart idea.</p>



<p>So then I will say that, uh, the, or in the end for a one, one and a zero,</p>



<p>zero is this because we already wrote that down in the truth table.</p>



<p>So really we&#8217;re going to be looking at inputs of one and zero.</p>



<p>So that means, uh, if we&#8217;re applying an, or to that,</p>



<p>applying an or to that, the final result should actually be one.</p>



<p>Okay.</p>



<p>So now we&#8217;ve got that second row.</p>



<p>We just have to look at the second to the last row.</p>



<p>So I&#8217;m going to go input for an X or of something else.</p>



<p>And the X or is going to be, oh gosh.</p>



<p>of an and</p>



<p>well xor let&#8217;s put that in the middle let&#8217;s say and on the left and or on the right and then we&#8217;ll</p>



<p>do an xor against them maybe you could put the parentheses on the other ones i don&#8217;t know i&#8217;m</p>



<p>struggling with notation clearly right now but so we say and exclusive or with the or but then what</p>



<p>Let&#8217;s put some more parentheses around it and we&#8217;ll say the and anded with an X or.</p>



<p>Now we&#8217;re running out of room here.</p>



<p>Can I get this like at the top maybe more?</p>



<p>How about that?</p>



<p>Okay, that&#8217;s a little bit better.</p>



<p>So we have and being anded against an X or and then I put parentheses around that.</p>



<p>There is a, there are special symbols you can use for this to make it more clear, but</p>



<p>for this to make it more clear, but I&#8217;m not really trying to explain that right now.</p>



<p>I just want you to see how the gates work.</p>



<p>So we have, then the next two operators are in, oh gosh, yeah, we&#8217;re XORing against two</p>



<p>things.</p>



<p>So on the right side, the OR is ORing and OR, and then on its right side is the AND.</p>



<p>So maybe I should do, I don&#8217;t know, I guess I&#8217;ll put parentheses right there to make it</p>



<p>seem a little bit more clear.</p>



<p>So now we&#8217;ve basically got an XOR and on its left side what&#8217;s happening underneath it is an</p>



<p>anding which is the middle of an and on the left and an XOR on the right and then the</p>



<p>the right side of the XOR is</p>



<p>then the the right side of the XOR that was my LL I&#8217;m talking to me again</p>



<p>on its left sorry it&#8217;s oaring on its on its right and then under the or it&#8217;s got an or on the left</p>



<p>and an and on the right okay so we&#8217;ve written all these down in a way that&#8217;s okay not great but okay</p>



<p>and i&#8217;m just going to do one one zero one one zero zero and then um i&#8217;ll make another video in the</p>



<p>future about truth tables if everyone is super interested but that&#8217;s that&#8217;s not really what i</p>



<p>I&#8217;ll make a video where the truth tables look proper and nice and full and all that stuff.</p>



<p>So let&#8217;s do, what is the answer between the, oh, I have to scroll up a little bit to see that.</p>



<p>So the left side of the XOR had an anding of an and and an XOR.</p>



<p>So that was this right here.</p>



<p>So the result of that was a one.</p>



<p>and an end and that was a one so I have two ones basically so this XOR is going to output</p>



<p>a zero because it&#8217;s it&#8217;s got two ones as an input or as inputs okay so then I guess I could copy</p>



<p>paste this to make it a little bit easier on myself to write it all out and I could just say</p>



<p>let&#8217;s not the whole entire thing to get to that highest level so I you know again I can just kind</p>



<p>I, you know, again, I can just kind of keep the whole thing copy pasted and you know,</p>



<p>the original input bit sequence, uh, I can just nod it.</p>



<p>I can just change that zero to a one.</p>



<p>So let&#8217;s just double check all our levels here to make sure that I did this correctly.</p>



<p>You never know.</p>



<p>So the input not, we know what that is for the end and the X or where&#8217;s the end and the</p>



<p>X or, okay.</p>



<p>So bottom left.</p>



<p>What did I do wrong?</p>



<p>Input.</p>



<p>Oh, that was, those were just the basics.</p>



<p>Okay.</p>



<p>So that&#8217;s not a combination.</p>



<p>Okay, so that&#8217;s not a combination.</p>



<p>Let me just double check the basics for the anding.</p>



<p>Zero and zero and zero and then zero and then one and then one.</p>



<p>And then here it should be a one and then the or should be one and should be zero.</p>



<p>And here the and should be one and the or should be one.</p>



<p>Okay, so I&#8217;ve got the basics, right?</p>



<p>And then on line 15 here, we&#8217;re looking at</p>



<p>an AND and an XOR. I guess I just did both of those at the same time. Okay, so the AND is a</p>



<p>1 and the XOR is a 1. And then the next one, the OR and the AND, it&#8217;s a 1 and a 0. Okay.</p>



<p>And then we&#8217;re ANDing the AND and the XOR. So that&#8217;s a 1, 1, 0, 1. The answer should be a 1.</p>



<p>That matches the diagram. Okay. And then the ORing of the OR and the AND on the right side,</p>



<p>the or and the and on the right side, that&#8217;s a one.</p>



<p>So that matches the diagram.</p>



<p>And then when we&#8217;re doing the whole thing, except for the knot,</p>



<p>it should be a zero at the top.</p>



<p>Okay, good.</p>



<p>And then finally, when we invert it at the very top, it&#8217;s a one.</p>



<p>So keep that in mind.</p>



<p>You can build and build and build in a hierarchical manner.</p>



<p>I mean, think if I started adding a bunch more stuff on top of this knot,</p>



<p>maybe if there were a bunch of other circuits somewhere else</p>



<p>and they were combining and combining like many layers.</p>



<p>This is the sort of thing that could help you.</p>



<p>Drawing, I think, is a little bit easier, but this could help you to just draw out a little table.</p>



<p>And of course, you want to have a giant table showing all combinations somewhere,</p>



<p>just to make sure that you can just look it up quickly.</p>



<p>But yeah.</p>



<p>Okay, so I think this is all I wanted to talk about.</p>



<p>Let me just double check.</p>



<p>All right.</p>



<p>So this is all I wanted to talk about for this video,</p>



<p>about logical gates and the basics and kind of helping yourself with a little bit of a table.</p>



<p>yourself with a little bit of a table. In future videos, I&#8217;ll talk about a proper table, perhaps.</p>



<p>And I hope you&#8217;ve learned a little bit and laughed a little bit at me struggling to do this on the</p>



<p>fly without a pre-made example. And I hope you had a little bit of fun and learned a little bit</p>



<p>of stuff. And I&#8217;ll see you in the next video. Thanks for watching. Hey, everybody. Thanks for</p>



<p>watching this video again from the bottom of my heart. I really appreciate it. I do hope you did</p>



<p>If you could do me a please a small little favor</p>



<p>Could you please subscribe and follow this channel or these videos or whatever it is you do on the current social media?</p>



<p>It&#8217;s a website that you&#8217;re looking at right now</p>



<p>It would really mean the world to me and it&#8217;ll help make more videos and grow this community</p>



<p>So we&#8217;ll be able to do more videos longer videos better videos or just i&#8217;ll be able to keep making videos in general</p>



<p>So, please do do me a kindness and and subscribe</p>



<p>I&#8217;m sleeping in the middle of the night and I just wake up because I know somebody subscribed or followed.</p>



<p>It just wakes me up and I get filled with joy.</p>



<p>That&#8217;s exactly what happens every single time.</p>



<p>So you could do it as a nice favor to me or you could troll me if you want to just wake me up in the middle of the night.</p>



<p>Just subscribe and then I&#8217;ll just wake up.</p>



<p>I promise that&#8217;s what will happen.</p>



<p>Also, if you look at the middle of the screen right now, you should see a QR code which you can scan in order to go to the website,</p>



<p>which I think is also named somewhere at the bottom of this video.</p>



<p>and it&#8217;ll take you to my main website where you can just kind of like see all the videos I published and</p>



<p>the services and tutorials and things that I offer and all that good stuff.</p>



<p>And if you have a suggestion for clarifications or errata or just future videos that you want to see,</p>



<p>please leave a comment.</p>



<p>Or if you just want to say, hey, what&#8217;s up? What&#8217;s going on?</p>



<p>You know, just send me a comment, whatever.</p>



<p>I also wake up for those in the middle of the night.</p>



<p>I wake up in a cold sweat and I&#8217;m like,</p>



<p>it would really mean the world to me.</p>



<p>I would really appreciate it.</p>



<p>So again, thank you so much for watching this video</p>



<p>and enjoy the cool music</p>



<p>as I fade into the darkness,</p>



<p>which is coming for us all.</p>



<p>Thank you.</p>
<p>The post <a href="https://www.NeuralLantern.com/logic-gates-crash-course-learn-and-or-xor-not-build-circuits/">Logic Gates Crash Course: Learn AND, OR, XOR, NOT &amp; Build Circuits</a> appeared first on <a href="https://www.NeuralLantern.com">NeuralLantern.com</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://www.NeuralLantern.com/logic-gates-crash-course-learn-and-or-xor-not-build-circuits/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>Master Bitwise Operators: OR, AND, NOT, XOR, NOR for Beginners</title>
		<link>https://www.NeuralLantern.com/master-bitwise-operators-or-and-not-xor-nor-for-beginners/</link>
					<comments>https://www.NeuralLantern.com/master-bitwise-operators-or-and-not-xor-nor-for-beginners/#respond</comments>
		
		<dc:creator><![CDATA[mike]]></dc:creator>
		<pubDate>Mon, 30 Jun 2025 06:15:25 +0000</pubDate>
				<category><![CDATA[Computer Science]]></category>
		<category><![CDATA[Videos]]></category>
		<category><![CDATA[AND operator]]></category>
		<category><![CDATA[binary logic]]></category>
		<category><![CDATA[binary operations]]></category>
		<category><![CDATA[bit manipulation]]></category>
		<category><![CDATA[bitwise operators]]></category>
		<category><![CDATA[C programming]]></category>
		<category><![CDATA[coding for beginners]]></category>
		<category><![CDATA[coding tips]]></category>
		<category><![CDATA[computer science basics]]></category>
		<category><![CDATA[NOR operator]]></category>
		<category><![CDATA[NOT operator]]></category>
		<category><![CDATA[OR operator]]></category>
		<category><![CDATA[programming tutorial]]></category>
		<category><![CDATA[tech tutorials]]></category>
		<category><![CDATA[XOR operator]]></category>
		<guid isPermaLink="false">https://www.NeuralLantern.com/?p=173</guid>

					<description><![CDATA[<p>Learn bitwise operators (OR, AND, NOT, XOR, NOR) with clear examples. Perfect for beginners mastering binary logic in programming.</p>
<p>The post <a href="https://www.NeuralLantern.com/master-bitwise-operators-or-and-not-xor-nor-for-beginners/">Master Bitwise Operators: OR, AND, NOT, XOR, NOR for Beginners</a> appeared first on <a href="https://www.NeuralLantern.com">NeuralLantern.com</a>.</p>
]]></description>
										<content:encoded><![CDATA[
<figure class="wp-block-embed is-type-video is-provider-youtube wp-block-embed-youtube wp-embed-aspect-16-9 wp-has-aspect-ratio"><div class="wp-block-embed__wrapper">
<iframe title="Master Bitwise Operators: OR, AND, NOT, XOR, NOR for Beginners" width="1380" height="776" src="https://www.youtube.com/embed/mL_wTRllqtc?feature=oembed" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share" referrerpolicy="strict-origin-when-cross-origin" allowfullscreen></iframe>
</div></figure>



<p>Want to understand bitwise operators? This video dives into OR, AND, NOT, XOR, and NOR with easy-to-follow examples. Learn how to use these operators for flags, masks, and more in programming. Perfect for beginners or anyone wanting to master binary logic in C or other languages. I break it down with real examples, a touch of humor, and no fluff. Subscribe for more coding tutorials, and check out my site for extra resources. Drop a comment with your questions or video ideas!</p>



<p>Introduction to Logical Operators 00:00:00<br>Explanation of Bitwise OR 00:00:35<br>OR Operation Examples 00:01:01<br>Bitwise OR with Multiple Bits 00:02:12<br>Using OR for Flags 00:03:52<br>Introduction to Logical AND 00:08:06<br>AND Operation Examples 00:08:29<br>Using AND as a Mask 00:10:00<br>Checking Specific Bits with AND 00:11:17<br>Introduction to NOT Operation 00:13:36<br>Introduction to NOR Operation 00:14:38<br>Introduction to XOR Operation 00:16:37<br>XOR and Neural Networks 00:16:53<br>Conclusion and Call to Action 00:18:38</p>



<p>Thanks for watching!</p>



<p>Find us on other social media here:</p>



<ul class="wp-block-list">
<li>https://www.NeuralLantern.com/social</li>
</ul>



<p>Please help support us!</p>



<ul class="wp-block-list">
<li>Subscribing + Sharing on Social Media</li>



<li>Leaving a comment or suggestion</li>



<li>Subscribing to our Blog</li>



<li>Watching the main &#8220;pinned&#8221; video of this channel for offers and extras</li>
</ul>



<p>Hey everybody! In this video I&#8217;m going to talk about basic logical operators such as OR and AND.</p>



<p>Uh so let&#8217;s let&#8217;s dive right into it. What am I talking about with the OR and AND?</p>



<p>Suppose for the sake of argument that this notepad is totally dark and I wanted it to be really light</p>



<p>and then I have to go into the system settings to fix it. Sorry let me change my theme.</p>



<p>How about that?</p>



<p>Okay.</p>



<p>So suppose for the sake of argument, we&#8217;ve got, you know, a couple of bits.</p>



<p>These are going to be a bitwise operations for the most part.</p>



<p>In other languages, sometimes we will say logical operator, but actually we&#8217;re just</p>



<p>talking about values rather than bits individually.</p>



<p>So these are bitwise operators.</p>



<p>Imagine we have like a couple of bits.</p>



<p>Remember the possible values for bits are just, you know, a zero and a one binary.</p>



<p>So suppose we have a couple of values.</p>



<p>values, let&#8217;s say we have a zero here and a one.</p>



<p>So if I apply a logical or to the zero and the one,</p>



<p>the result is going to be a one because either the first bit or the second bit are a one.</p>



<p>You could also expand these operators to have multiple sets of bits,</p>



<p>but we&#8217;re just going to do, you know, one set against another set.</p>



<p>In this case, each set is just one bit long, but we&#8217;ll do, we&#8217;ll do a more complicated stuff in a minute.</p>



<p>If I have a zero and a one, then the answer there is, well, let me just put or maybe.</p>



<p>The answer is a one.</p>



<p>I&#8217;ll put or maybe at the top, just like or to let you know that we&#8217;re doing ors here</p>



<p>on the top.</p>



<p>So if we have a zero and a one, the answer is going to be a one.</p>



<p>If we have a one and a zero, the answer is going to be a one.</p>



<p>Also, if we have two ones, which looks like an L over there, I got to work on my penmanship.</p>



<p>Then the answer is also going to be a one.</p>



<p>if either of the bits in question are a one then the answer should be a one. The only case with an</p>



<p>OR that results in a zero is if both of the bits are zero because neither the first or the second</p>



<p>are actually a one right so this is the basic idea of using an OR operator and you can also do this</p>



<p>with multiple bits at the same time like for example we could say let&#8217;s take a bunch of random</p>



<p>work on the it&#8217;s the pressure dude the l&#8217;s are driving me crazy okay oh my god okay so i do that</p>



<p>and i let go okay i&#8217;m just going to put some random bits uh underneath the the first set of</p>



<p>random bits put like a zero here and then like a one here maybe and we&#8217;ll say that we&#8217;re going to</p>



<p>do a logical or just like you might think of doing a you know addition or subtraction we&#8217;ll just say</p>



<p>you know, addition or subtraction. We&#8217;ll just say we&#8217;re going to or these two sets of bits.</p>



<p>Actually, these are six on the top and six on the bottom. If I add two more, then it&#8217;ll be a nice</p>



<p>little bite for the top and the bottom. So I&#8217;m just going to do that, you know, to have eight</p>



<p>bits on the top and eight bits on the bottom. Okay. So if I just want to logically or two sets</p>



<p>of bits, literally, I just have to do one pair of bits at a time. So a one or zero is just a one.</p>



<p>One or zero is just a one, a zero or one is a one, a one or zero is a one, a zero or one</p>



<p>is a one.</p>



<p>And then these ones, everything is just a one.</p>



<p>Okay.</p>



<p>So that was too easy.</p>



<p>Maybe if I, I don&#8217;t know, maybe if I change one of these ones to a zero, then we would</p>



<p>actually be able to have a zero somewhere in here.</p>



<p>So that&#8217;s a logical or a bitwise or operator or operation.</p>



<p>So you can, you can kind of use this in various ways.</p>



<p>can kind of use this in various ways i mean obviously if you want to manipulate some bits</p>



<p>this can be pretty useful inside of the machine but there was kind of an old school way that</p>



<p>people did flags with arguments they would basically say something like this they would go</p>



<p>in their computer program they would say you know flag a name it something like turn on the display</p>



<p>or enable caching or just like whatever right so we&#8217;ll just have a flag we&#8217;ll call it flag a</p>



<p>that value is equal to a one and then maybe flag b its value is equal to a two and then flag c</p>



<p>its value would be a four and then we basically just double the value of the flag and the reason</p>



<p>for that c d e f i&#8217;ll just stop with f maybe oh wait that was supposed to be 16 and that&#8217;s 32.</p>



<p>the reason for that is if you double the value of each flag so that uh</p>



<p>and then you can do a bitwise or against all of these flags and sort of combine multiple flags.</p>



<p>Because if you think about it, if we&#8217;re talking about binary,</p>



<p>if we suppose this is just a regular eight bit number, then, you know, the first bit has a</p>



<p>strength of one. If you&#8217;ve seen my other videos for converting between binary and hex,</p>



<p>the second bit has a strength of two. The next bit has a strength of four and then eight and</p>



<p>and then 32 and 64 and then 128.</p>



<p>And so if you look at the flags,</p>



<p>1, 2, 4, 8, 16, 32,</p>



<p>they map to only one bit.</p>



<p>It&#8217;s not going to be some kind of random pattern for these numbers.</p>



<p>It&#8217;s literally going to be flag A is going to look like this.</p>



<p>1, 2, 3, 4, 5, 6, 7, 8.</p>



<p>And then flag B is going to look like this.</p>



<p>1, 2, 3, 4, 5, 6, 7, 8.</p>



<p>five, six, seven, eight. And flag D is going to look like this. Whoops. Let me make that green.</p>



<p>Still getting used to this. Oh, sorry. C is the next one. One, two, three, four, five,</p>



<p>six, seven, eight. Can you see the pattern here? Let me just do D and be done with it at this</p>



<p>point. One, two, three, four, five, six, seven, eight. So because we&#8217;re increasing the value of</p>



<p>the flags by a power of two, or by a power of two, they&#8217;ll always correspond to just one bit.</p>



<p>they&#8217;ll always correspond to just one bit, which means if you apply a logical or operation,</p>



<p>you can represent a bunch of different flags with just one number.</p>



<p>Think about this.</p>



<p>What if I wanted to have, oh, I don&#8217;t know.</p>



<p>Let me erase this.</p>



<p>What if I wanted to have some, let&#8217;s say I wanted flag A and flag D and flag F just for</p>



<p>the sake of argument.</p>



<p>Dang, this pen.</p>



<p>It&#8217;s actually my fault completely, but I need to practice.</p>



<p>but I need to practice F okay and DNF so that would basically be you know 1 2 3 4 5 6 7 8</p>



<p>and then D would be the 8 so a 1 0 0 0 there and then a bunch of zeros elsewhere and then the F</p>



<p>So if we did an OR between all of those, then the OR is just basically 00101001.</p>



<p>And if you convert that from binary to decimal, what is that?</p>



<p>That&#8217;s a 1248 plus 8 plus 1248 and then a 32.</p>



<p>So 41.</p>



<p>just write down the number 41 and if the programmer is smart enough to you know parse all the bits</p>



<p>and everything then they&#8217;ll know that you have flags a and d and f set that&#8217;s not necessarily</p>



<p>something that all the modern programs do anymore it was much more popular in the olden days but i</p>



<p>think some people still kind of do it especially if they&#8217;re programming in c and other languages</p>



<p>where they want speed it&#8217;s pretty fast to look at bits inside of the machine so keep that in mind</p>



<p>Keep that in mind now we know how to do an OR operation and we know one reason that it might be useful and</p>



<p>Yeah, okay. I&#8217;m gonna move on to the next operation</p>



<p>So clearing the screen now</p>



<p>Hello little doggy he barked and now he&#8217;s in the room</p>



<p>Let&#8217;s do</p>



<p>The logical AND operation okay, so suppose we have two bits here</p>



<p>in a one only if both of the input bits are a one i&#8217;m gonna whoops i accidentally cleared the whole</p>



<p>entire thing let me forget where my red pen is okay and okay so if we have a zero and a zero</p>



<p>the result is zero because neither of those are a one if we have a zero and a one the result is</p>



<p>still going to be zero because we need both bits to be a one to result in a one so then that means</p>



<p>would also result in a zero. So you get a bunch of zeros until finally you have an input pattern</p>



<p>that is just two ones. And then finally the result is one. So that&#8217;s a logical and.</p>



<p>Let me do a quick example so we can and a bunch of bits together. I&#8217;m just going to do more</p>



<p>random bit patterns. So there&#8217;s another L there. I&#8217;m cringing. I&#8217;m self-cringing. One, two, three,</p>



<p>okay so then i&#8217;ll do like another one there and like a zero there and a zero maybe a couple of</p>



<p>ones maybe three ones and then a zero and then one i guess and we&#8217;ll just say that we&#8217;re going</p>



<p>to end those together so and oh man i&#8217;m mixing uppercase and lowercase like crazy</p>



<p>so uh to end them together you know that bit position right here that&#8217;s going to be a one</p>



<p>and then we have a zero because they don&#8217;t match they&#8217;re not both one and then we have another zero</p>



<p>a one and then we have a zero and a zero and a zero and a one so this is a logical and you can</p>



<p>use logical ands for a wide variety of things but one thing you can kind of do somewhat easily is to</p>



<p>use one number as a mask against another number for example notice how uh suppose this was the</p>



<p>input number let&#8217;s just say we have the input number up top and maybe you wanted to make sure</p>



<p>because you&#8217;re you&#8217;re checking for those bits individually or maybe you want to just prevent</p>



<p>the input from having certain bits on for some other reason well you can you can apply the mask</p>



<p>as the second bit and use a logical and i&#8217;ll say mask here sorry you can apply a mask as the second</p>



<p>bit pattern and notice how in the answer there are only ones where both you know the input and</p>



<p>means if I wanted to just control only which ones are allowed I can use the mask notice how the mask</p>



<p>has ones in these positions and there are definitely no zeros sorry there are definitely</p>



<p>no ones in any position where a mask had a zero so the mask can kind of like you know mute or mask</p>



<p>or control the input pattern if that makes sense hopefully another thing we could do if we wanted</p>



<p>if one bit exists. Let me go ahead and clear this real fast. I&#8217;m going to just do maybe four</p>



<p>bits this time. So we could obviously do an and against four zeros, and this would result in just,</p>



<p>you know, a resulting pattern of zero. So this is not super useful. The result would just</p>



<p>definitely be four zeros. But notice again how the second pattern is sort of controlling what&#8217;s</p>



<p>allowed to go through from the first pattern. Suppose I wanted to check to see if that particular</p>



<p>particular bit was on or off.</p>



<p>All I have to do is mask it with a one in the correct pattern.</p>



<p>So, you know, the second bit that I just wrote down on the bottom row,</p>



<p>I just want to see if that second bit is on or off in the input pattern.</p>



<p>I don&#8217;t care about any of the other bits.</p>



<p>That means the result will be this.</p>



<p>So now it&#8217;s much more easy for me to see if that bit is on.</p>



<p>I could just compare the value of those bits to a regular integer.</p>



<p>Like, for example, if we consider that this was the one and this was the two</p>



<p>considered that this was the one and this was the two and this was the four or sorry four and then</p>



<p>the eight I could just ask now if the final value equals two and then I would know if that bit was</p>



<p>on or not in the original pattern and so if I wanted to check to see if this other you know</p>



<p>bit was on I can move this over here and set that back to a zero so the resulting pattern would be</p>



<p>zeros then I&#8217;d ask myself is the resulting value equal to four no it&#8217;s equal to zero and so then</p>



<p>Another thing you can do that I&#8217;m going to talk about in a future video is just sort of shift the bits over.</p>



<p>You could, instead of checking to see if the value was a 4 or like a direct integer,</p>



<p>you could just sort of shift over a certain number of spots and then check to see if it was equal to 1 or 0.</p>



<p>Let me put this 1 back over into its original position just so that we&#8217;ll have something that had a 1.</p>



<p>is one from uh you know the right side if it&#8217;s one to the left from the right side</p>



<p>then i could just shift all the bits one to the right and end up with a pattern that is zero zero</p>



<p>zero one i&#8217;m not going to talk about bit shifting operations in this video but just know that you can</p>



<p>and you&#8217;ll see more of it in a future video so then you know this is another way to check to</p>



<p>see if a bit was on first you do a mask for that bit and then you shift bits and then you just</p>



<p>check to see if the final value is a zero or one which may or may not feel easier than checking for</p>



<p>or may not feel easier than checking for an actual integer in your program.</p>



<p>Okay, so we&#8217;ve done OR and also AND. The next bit pattern is called a NOT, which is really easy.</p>



<p>It&#8217;s literally just an inversion of the original bit pattern. So for the NOT, we don&#8217;t really take</p>



<p>two bits against each other. We just take an input bit and we just invert it. We&#8217;ll just say</p>



<p>So that&#8217;s a knot. Pretty easy. We could also knot, you know, a random bit pattern with Ls.</p>



<p>So I swear, somebody&#8217;s going to show up and this is their first computer science video.</p>



<p>They&#8217;re going to go tell their parents, hey, there&#8217;s Ls in computer science.</p>



<p>So sorry. I&#8217;m so sorry. Okay. So I got four there. So if I knot those, then that&#8217;s pretty easy.</p>



<p>It&#8217;s just going to be the opposite, you know, an inversion.</p>



<p>you know, an inversion.</p>



<p>One, zero, one, zero.</p>



<p>Let me just double check that I did that correctly.</p>



<p>Yeah, so that&#8217;s the knot pattern.</p>



<p>No big deal.</p>



<p>Pretty easy.</p>



<p>So then maybe the next thing that we can talk about is the nor,</p>



<p>which just means not or.</p>



<p>So let me draw that out real fast just to show you what I&#8217;m talking about.</p>



<p>So if we do nor, pretty much you can imagine first taking the or and then knotting it.</p>



<p>So inverting the or.</p>



<p>the OR. So for example, if we have two bits here, actually, let me, let me do, let me do a</p>



<p>sequential counter. Cause I think that&#8217;s more fun. I&#8217;m counting right now from one to a three</p>



<p>or a actually, I do that in the last one. I started with zero. I hope let&#8217;s count from zero</p>



<p>to three. So zero and then one and then two and then three. So I&#8217;m counting in binary.</p>



<p>two input bits and we&#8217;re going to do a nor then the first thing we probably want to do is take</p>



<p>the or operator so that would be a zero here i&#8217;ll just put or in parentheses just to let you know</p>



<p>that this is kind of a nice first step you could memorize nor if you wanted to but i don&#8217;t i don&#8217;t</p>



<p>really remember how to do it without doing these steps so uh it&#8217;s going to be ones for everything</p>



<p>else because in the or you get a one if either of those is a one and then uh the next step is you</p>



<p>the or i&#8217;ll just put nor here just to let you well just to let you know that you&#8217;re uh well i</p>



<p>don&#8217;t know if i put nor then it kind of sounds like i&#8217;m norring that one bit doesn&#8217;t it so maybe</p>



<p>here i&#8217;ll say uh not just to let you know that this is just one step against the previous bit</p>



<p>so the knot is uh just going to be an inversion and so the nor of zero zero is one the nor of zero</p>



<p>nor of 1 1 is 0 and that&#8217;s how you do a nor and all of these logical or bitwise</p>



<p>operators can be used in circuits and circuit design and just you know other</p>



<p>types of logical operations I&#8217;m gonna move on let&#8217;s see the next one is gonna</p>



<p>be XOR that I wanted to talk about in this video so what is XOR it just means</p>



<p>exclusive or so it&#8217;s a little bit more complicated than or this is actually a</p>



<p>one because it has a history with neural networks. When you have a neural network that does not have</p>



<p>more than one, or sorry, if you have a neural network that does not have any hidden layers,</p>



<p>like if you just have an input layer and an output layer, then the neural network should</p>



<p>actually not be able to solve XOR. It should not be able to learn it. You have to increase the</p>



<p>topology of the neural network in some way, make it a little bit more complicated. For example,</p>



<p>one or more middle layers between the input and the output layers. If you understand neural</p>



<p>networks, it&#8217;s just kind of fun to know, oh, XOR stumps a shallow network and kind of starts to</p>



<p>prove that deep networks might be a little bit smarter or deepish at least. Okay. So XOR,</p>



<p>let&#8217;s start off by counting here. I&#8217;m going to do zero and zero, and then this is the number one,</p>



<p>and this is the number two, and this is the number three. And exclusive OR just basically means</p>



<p>just basically means an or but if both of the bits are one then it&#8217;s a zero so that means</p>



<p>either of the bits can be a one to produce a one but it must be exclusive the bit that is a one</p>



<p>can&#8217;t also be next to another bit that&#8217;s a one so let me show you so in is in a double zero</p>



<p>the answer is just going to be a zero in a zero and one the answer is going to be a one in a one</p>



<p>exclusive, the one is it has a, it has a buddy or a partner.</p>



<p>It&#8217;s not an exclusive one.</p>



<p>So we&#8217;ll say that that&#8217;s a zero.</p>



<p>So that&#8217;s the XOR.</p>



<p>I don&#8217;t know.</p>



<p>You could put like a, a, a not on top of that or an and on top of that or whatever</p>



<p>you wanted to do.</p>



<p>And we can make stuff that&#8217;s a lot more complicated, but these are the basics of</p>



<p>or and not XOR and NOR as bitwise operators.</p>



<p>So thank you for watching this video.</p>



<p>That&#8217;s all I have to say for now.</p>



<p>See you in the next one.</p>



<p>Hope you learned a little bit and had a little bit of fun.</p>



<p>I&#8217;m out.</p>



<p>social media website that you&#8217;re looking at right now it would really mean the world to me and it&#8217;ll</p>



<p>help make more videos and grow this community so we&#8217;ll be able to do more videos longer videos</p>



<p>better videos or just i&#8217;ll be able to keep making videos in general so please do do me a kindness</p>



<p>and uh and subscribe you know sometimes i&#8217;m sleeping in the middle of the night and i just</p>



<p>wake up because i know somebody subscribed or followed it just wakes me up and i get filled</p>



<p>with joy that&#8217;s exactly what happens every single time so you could do it as a nice favor to me or</p>



<p>it as a nice favor to me or you could you could troll me if you want to just wake me up in the</p>



<p>middle of the night just subscribe and then i&#8217;ll i&#8217;ll just wake up i promise that&#8217;s what will</p>



<p>happen also uh if you look at the middle of the screen right now you should see a qr code which</p>



<p>you can scan in order to go to the website which i think is also named somewhere at the bottom of</p>



<p>this video and it&#8217;ll take you to my main website where you can just kind of like see all the videos</p>



<p>i published and the services and tutorials and things that i offer and all that good stuff and</p>



<p>if you have a suggestion for uh uh clarifications or errata or just future videos that you want to</p>



<p>see please leave a comment or if you just want to say hey what&#8217;s up what&#8217;s going on you know</p>



<p>just send me a comment whatever i also wake up for those in the middle of the night i get i wake up</p>



<p>in a cold sweat and i&#8217;m like it would really it really mean the world to me i would really</p>



<p>appreciate it so again thank you so much for watching this video and um enjoy the cool music</p>



<p>the cool music as I fade into the darkness which is coming for us all.</p>



<p>Thank you.</p>
<p>The post <a href="https://www.NeuralLantern.com/master-bitwise-operators-or-and-not-xor-nor-for-beginners/">Master Bitwise Operators: OR, AND, NOT, XOR, NOR for Beginners</a> appeared first on <a href="https://www.NeuralLantern.com">NeuralLantern.com</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://www.NeuralLantern.com/master-bitwise-operators-or-and-not-xor-nor-for-beginners/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
	</channel>
</rss>
