<?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>two&#039;s complement Archives - NeuralLantern.com</title>
	<atom:link href="https://www.NeuralLantern.com/tag/twos-complement/feed/" rel="self" type="application/rss+xml" />
	<link>https://www.NeuralLantern.com/tag/twos-complement/</link>
	<description></description>
	<lastBuildDate>Mon, 29 Dec 2025 08:55:42 +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>two&#039;s complement Archives - NeuralLantern.com</title>
	<link>https://www.NeuralLantern.com/tag/twos-complement/</link>
	<width>32</width>
	<height>32</height>
</image> 
	<item>
		<title>x86-64 Assembly Bit Manipulation: AND, OR, XOR, NOT, Shifts &#038; Rotates Tutorial</title>
		<link>https://www.NeuralLantern.com/x86-64-assembly-bit-manipulation-and-or-xor-not-shifts-rotates-tutorial/</link>
					<comments>https://www.NeuralLantern.com/x86-64-assembly-bit-manipulation-and-or-xor-not-shifts-rotates-tutorial/#respond</comments>
		
		<dc:creator><![CDATA[mike]]></dc:creator>
		<pubDate>Mon, 29 Dec 2025 08:55:41 +0000</pubDate>
				<category><![CDATA[Assembly Language]]></category>
		<category><![CDATA[Coding]]></category>
		<category><![CDATA[Computer Science]]></category>
		<category><![CDATA[Videos]]></category>
		<category><![CDATA[AND OR XOR]]></category>
		<category><![CDATA[arithmetic shift]]></category>
		<category><![CDATA[assembly language tutorial]]></category>
		<category><![CDATA[assembly programming]]></category>
		<category><![CDATA[bit manipulation]]></category>
		<category><![CDATA[bit rotation]]></category>
		<category><![CDATA[bit shifting]]></category>
		<category><![CDATA[bitwise operations]]></category>
		<category><![CDATA[computer architecture]]></category>
		<category><![CDATA[gdb debugging]]></category>
		<category><![CDATA[logical shift]]></category>
		<category><![CDATA[low-level programming]]></category>
		<category><![CDATA[two's complement]]></category>
		<category><![CDATA[x86-64 assembly]]></category>
		<category><![CDATA[Yasm assembly]]></category>
		<guid isPermaLink="false">https://www.NeuralLantern.com/?p=272</guid>

					<description><![CDATA[<p>Learn bitwise operations in x86-64 assembly language including AND, OR, XOR, NOT, logical and arithmetic shifts, and bit rotations with practical examples and GDB debugging.</p>
<p>The post <a href="https://www.NeuralLantern.com/x86-64-assembly-bit-manipulation-and-or-xor-not-shifts-rotates-tutorial/">x86-64 Assembly Bit Manipulation: AND, OR, XOR, NOT, Shifts &amp; Rotates Tutorial</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="x86-64 Assembly Bit Manipulation: AND, OR, XOR, NOT, Shifts &amp; Rotates Tutorial" width="1380" height="776" src="https://www.youtube.com/embed/N8Nciq6l5IU?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>In this hands-on tutorial, we dive into bit manipulation in x86-64 assembly using Yasm on Ubuntu. We cover the basics of logical operations like AND, OR, XOR, and NOT, then move into shifting (logical vs arithmetic), rotating bits, and why signed vs unsigned matters for shifts.</p>



<p>I explain each concept on paper first, then show real code examples running in GDB to prove how the bits change. We look at patterns in registers, see what happens with negative numbers in two&#8217;s complement, and even touch on how shifts can multiply or divide by powers of 2.</p>



<p>Perfect if you&#8217;re learning low-level programming, reverse engineering, or just curious about how bits work under the hood. No prior assembly knowledge needed, but it&#8217;ll help if you&#8217;ve seen my other videos.</p>



<p>Like and subscribe for more assembly tutorials!</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.</p>



<p>In this video, we&#8217;re going to talk all about manipulating bits in x86-64 Yasm assembly within</p>



<p>Ubuntu.</p>



<p>But if you&#8217;re not using Yasm or you&#8217;re not on Ubuntu, this video is probably going to</p>



<p>be pretty useful to you anyway, because I&#8217;m going to talk about the basic concept of manipulating</p>



<p>bits in various ways.</p>



<p>We&#8217;re going to talk about some basic logical operators like ANDing, ORing, XORing, and</p>



<p>XORing, and then we&#8217;re going to talk about shifting the bits to the left and the right,</p>



<p>and then we&#8217;re going to talk about the difference between shifting without any respect for whether</p>



<p>the number inside of the bits is an actual integer, or whether we just consider them</p>



<p>to just be bits by themselves, or whether we&#8217;re actually respecting the bits as numbers,</p>



<p>and also we&#8217;re going to look at the rotation instruction.</p>



<p>So first I&#8217;m going to explain this, I&#8217;m going to write it down in a pad, and then I&#8217;m going</p>



<p>show you a program that actually does it just so we can prove that it all works.</p>



<p>Okay, so for starters, let me open up a little notepad here.</p>



<p>What the heck am I even talking about? Let me write this down because I forgot this on my</p>



<p>first take I spent like five minutes, blew right past the explanation of and and or and xor because</p>



<p>I forgot that that was supposed to be part of this video. We&#8217;re going to look at and or and xor</p>



<p>at least for now and then we&#8217;re going to look at shifting and then we&#8217;re going to look at rotating.</p>



<p>at rotating. Okay so first off what is anding? I&#8217;ve explained that in another video but long</p>



<p>story short and just requires that two bits that you&#8217;re comparing against each other are both a one</p>



<p>in order to receive a one and so any other pair like a zero versus a one or one versus a zero or</p>



<p>two zeros are just going to be a zero. So and means both bits that you&#8217;re comparing have to be a one</p>



<p>The OR is pretty easy.</p>



<p>If either of the bits is a 1, then the result is going to be 1.</p>



<p>So if I say 1 versus 1, the result is going to be 1.</p>



<p>If I say 0 versus 1, the result is going to be a 1.</p>



<p>Or if I say 1 versus 0, the result is going to be a 1.</p>



<p>In the only case where you end up with a 0, it&#8217;s just going to be 0 versus 0 results in a 0.</p>



<p>To upgrade to exclusive OR, basically exactly 1 bit needs to be a 1.</p>



<p>bit needs to be a one and if two or zero are a one then the result is a zero which means here when</p>



<p>we have the two ones at the top the answer is going to be a zero these are the two stay the</p>



<p>same and this one stays the same so that&#8217;s xor again i have another video where i explain this</p>



<p>a little bit better but i&#8217;m just doing like a quick overview shifting is pretty interesting</p>



<p>because let me do a pattern let&#8217;s say zero one one zero suppose we just have four bits</p>



<p>to the left or to the right. So imagine left, if I shift them to the left, then what I&#8217;m really</p>



<p>doing is I&#8217;m just taking off that zero on the end and padding on the right with a zero. And then if</p>



<p>I&#8217;m shifting to the right, then well, it&#8217;s to the right. I&#8217;m just going to, you know, take off,</p>



<p>let&#8217;s see the zero on the right side and pad with the zero on the left. Be careful though, because</p>



<p>or logical shifting. I haven&#8217;t actually shifted with respect to the original number. Think</p>



<p>about this. That number right there on line three, if we just consider that an unsigned</p>



<p>integer or just bits, then what I just did with the shifting is fine. But what if that</p>



<p>was a two&#8217;s complement number that can represent a signed integer? If it&#8217;s two&#8217;s complement</p>



<p>or if it&#8217;s just like a signed integer, then the leftmost bit being a zero tells me that</p>



<p>result of my left shift, there&#8217;s a one now in that first position, which tells me that&#8217;s</p>



<p>probably a negative number.</p>



<p>We could face a similar problem with shifting to the right.</p>



<p>I mean, we didn&#8217;t this time.</p>



<p>It just looks like it actually shifted and the answer is going to end up being right.</p>



<p>But what if we shifted something else right?</p>



<p>Let&#8217;s see, what am I going to do here?</p>



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



<p>What if I shifted that number one to the right?</p>



<p>The answer would be zero, you know, one, one, zero, right?</p>



<p>you know 110 right but then that&#8217;s wrong because the original number was negative because there&#8217;s</p>



<p>a one in the first position but the result is a zero so if i&#8217;m not careful about what instructions</p>



<p>i&#8217;m using and how to respect whether the number i&#8217;m shifting is actually considered an integer</p>



<p>assigned integer or if it&#8217;s just bits if i don&#8217;t respect that then i could end up ruining the</p>



<p>number so keep that in mind we&#8217;re going to do several examples of that i&#8217;m not going to show</p>



<p>shift by hand I&#8217;m just going to show you what the instructions in the assembler</p>



<p>will do so then the other thing that we should talk about is rotating so imagine</p>



<p>that I rotate this number one to the right well nothing really happens</p>



<p>visually but what you&#8217;re supposed to do if we rotate to the right you take the</p>



<p>number on the very right side and you just pop it onto the front so it sort of</p>



<p>it doesn&#8217;t fall off and get replaced by a zero or get replaced by a one depending</p>



<p>moves to the other side so if I shift this again maybe let&#8217;s shift it one more</p>



<p>time to the right I&#8217;m gonna take that one and pop it off the right side and</p>



<p>put it on the very front so see do you see how there it&#8217;s kind of rotating I do</p>



<p>this one more time actually let me copy paste this I&#8217;ll take that number on the</p>



<p>right side pop it off put it back on the front then if I do it again take that</p>



<p>zero pop it off put it back on the front notice how it eventually gets back to</p>



<p>the original pattern and I would have to rotate you know exactly four times to</p>



<p>to get that to happen same same thing applies for rotating to the left i&#8217;m not going to show you</p>



<p>because uh it&#8217;s it&#8217;s the same thing as rotating to the right just in a different direction</p>



<p>one thing that i forgot to say a moment ago when i was talking about shifting is uh think about this</p>



<p>if we shift to the right pretend that uh we don&#8217;t really care that much let&#8217;s let me put some extra</p>



<p>zeros here so that we don&#8217;t have to carry too much we don&#8217;t have to care too much about what&#8217;s</p>



<p>happening with positive or negative. If you know how to convert to binary, which I&#8217;ve explained in</p>



<p>other videos, then you&#8217;ll know this number is, let&#8217;s see, there&#8217;s a one and a two, and then these</p>



<p>positions are four and eight. So this should be a 12, right? If I shift this to the right,</p>



<p>I should be dividing this by two because the base of binary is two. So every time you kind of like</p>



<p>move to the left in terms of what digit you&#8217;re looking at, you&#8217;re increasing the power of that</p>



<p>every time you move to the right you&#8217;re decreasing the power of the digit by two</p>



<p>so that means if I shift the entire thing to the right I should be dividing the whole thing by two</p>



<p>right not just one bit so if I just take a zero off of there and put it on there I&#8217;ve now shifted</p>



<p>all the bits shifted all the bits one to the right I should end up with the six let&#8217;s just</p>



<p>compute what it is there&#8217;s a one there and there&#8217;s a two there and there&#8217;s a four there what&#8217;s four</p>



<p>plus two that&#8217;s six so this is actually six in binary or the original number divided by two</p>



<p>because we shifted to the right on the other hand if I take this number one more time and</p>



<p>just kind of shift it to the left I should multiply it by two so that means I should</p>



<p>expect to see a 24 let me just remove one of those zeros and put it on the right side there</p>



<p>this is not a rotation I&#8217;m just kind of like filling in zeros I&#8217;m keeping it simple with</p>



<p>the shifted number this is a 1, a 2, and a 4 again if you don&#8217;t know how to convert</p>



<p>from binary to decimal or back see my other videos so then we basically have</p>



<p>an 8 here and a 16 what&#8217;s 8 plus 16 that&#8217;s 24 24 is twice of 12 so we have</p>



<p>multiplied by 2 so you could multiply by 4 by shifting twice multiply by 8 by</p>



<p>shifting 3 times you know whatever you want to do but shifting is is like a</p>



<p>is like a shortcut besides just to move the bits it&#8217;s also a shortcut to multiply and divide by two</p>



<p>okay so that&#8217;s the basic idea let me start working on a little program here for you before I continue</p>



<p>I just want you to know that my program it&#8217;s got stuff in it already we&#8217;ve got a make file here</p>



<p>if I uh I edit the make file I just have a make file set up to build the program so again this</p>



<p>is specific to just you know bits we&#8217;re not going to talk about make files see my other videos if</p>



<p>you want to know how to make your own make file same thing for this gdb.txt file I&#8217;ve just put</p>



<p>commands that I&#8217;m going to send to gdb my debugger of choice this is not a gdb video I haven&#8217;t</p>



<p>actually made my gdb video yet so look out for that in this in the somewhat near future</p>



<p>so we&#8217;re just going to focus on the actual program for now anyway so I&#8217;ve got a solution</p>



<p>Anyway, so I&#8217;ve got a solution already set up here.</p>



<p>Let me start copy pasting some stuff in there.</p>



<p>Going to copy paste my data section.</p>



<p>So first off,</p>



<p>my sample program is just gonna have codes for writing,</p>



<p>you know, with the system call</p>



<p>and exiting with the system call.</p>



<p>And then I&#8217;m gonna output to standard output</p>



<p>and I&#8217;m gonna do a zero return code.</p>



<p>If you don&#8217;t know that,</p>



<p>see my other videos that I&#8217;ve already put out.</p>



<p>I&#8217;m gonna make a sample string where I just say,</p>



<p>I just say hello my name is Gibson Montgomery Gibson that&#8217;s not my name but I love those names</p>



<p>I&#8217;m just going to say hello basically when the program starts then I have some bit strings here</p>



<p>that will help me with the you know help me demonstrate some of the bitwise operations</p>



<p>the ending and the oring and the shifting and whatever and then I&#8217;m going to put a negative</p>



<p>number here as a variable just to prove to you that sometimes the bitwise or logical shifting</p>



<p>break a number if the number is supposed to actually be assigned integer and and use that</p>



<p>as evidence for why you should use arithmetic shifting so now I&#8217;m going to start my program</p>



<p>here let&#8217;s see my entry point should start at line 30 I got to be super careful about this</p>



<p>because if I don&#8217;t know 26 if I don&#8217;t then all of my debug statements are going to have to be</p>



<p>it lined up correctly so i&#8217;m basically just going to print the hello message and then maybe you know</p>



<p>what at the very end i&#8217;m going to exit from the system with a system call so basically if we run</p>



<p>this program again system calls and everything like that are not part of this video see my other</p>



<p>videos but uh if this works we should see just like a simple message okay so that&#8217;s it my name</p>



<p>Conmary Gibson. Okay.</p>



<p>So then the next thing that I&#8217;m going to do is I&#8217;m going to show you a bitwise</p>



<p>and operation. So I&#8217;m going to copy paste that should start on line 42.</p>



<p>And if I get this wrong, the debugging is going to be awful.</p>



<p>I was trying to make this a pure assembly program without a bunch of extra work.</p>



<p>I guess I could have linked GCC so I could just print results to the terminal,</p>



<p>but whatever too late now. So it starts on 42.</p>



<p>and ends on 51 okay so I think that&#8217;s good so the instruction for ending doing</p>



<p>a logical and between two registers which are full of bits and then what</p>



<p>will happen is every bit gets anded against its own course or I guess the</p>



<p>corresponding bit in the other other register is just and so what I&#8217;m doing</p>



<p>first is I&#8217;m gonna set up the registers so I&#8217;m gonna move the a sequence which</p>



<p>sequence, which if you look up is just, you know, I put a bunch of bits. So like in hex,</p>



<p>I like to type hex more than binary when I&#8217;m just kind of putting stuff in there.</p>



<p>So, you know, each F is basically four ones. So it&#8217;s going to be like, I guess, 16 ones,</p>



<p>and then a bunch of zeros, and then, you know, a few ones, and then some zeros and ones.</p>



<p>So I&#8217;m just making a little pattern for bits A. Don&#8217;t think that they mean anything right now.</p>



<p>And I&#8217;m going to make a different pattern with bits B. And when we look into the debugger,</p>



<p>And when we look into the debugger, we should see the before and after patterns so we can kind of see what the AND instruction did.</p>



<p>So I&#8217;m going to move bits A and bits B into R10 and R11.</p>



<p>Then I&#8217;m going to move, so these are going to be like the original bits that we can inspect later.</p>



<p>this AND instruction against R11 which is the B pattern. So I&#8217;m basically taking the A pattern</p>



<p>and I&#8217;m ANDing it against the B pattern but I&#8217;m also loading up the registers so we can see</p>



<p>the A pattern then the B pattern and then the result of ANDing them together.</p>



<p>Finally on line 50 here I&#8217;m using a NOPE which is just a non-operation so that I can easily</p>



<p>break the debugger so we can sort of inspect the program and see what&#8217;s going on inside of there.</p>



<p>program and see what&#8217;s going on inside of there. You know what, let me, uh, let me open this up</p>



<p>again here so that I can control where I&#8217;m breaking. So 48 is where the nope is. That&#8217;s</p>



<p>totally wrong. I&#8217;ve already ruined my program somehow. It&#8217;s going to be 50, I guess. All right,</p>



<ol start="50" class="wp-block-list">
<li>And what I&#8217;m doing inside of this, and again, this is not a GDB video. I&#8217;m just saying,</li>
</ol>



<p>let&#8217;s break at line 50 so I can kind of poke around. And I&#8217;m going to comment all these</p>



<p>And I&#8217;m going to comment all these things out for now.</p>



<p>That&#8217;s going to happen at the very end.</p>



<p>It&#8217;s going to be majestic.</p>



<p>How many different things we can look at.</p>



<p>So I&#8217;m telling GDB not to execute any of these instructions, except for the, uh,</p>



<p>the break point instructions.</p>



<p>So we can just break on line 50.</p>



<p>Okay.</p>



<p>Hopefully this works.</p>



<p>I&#8217;m going to now use make debug, which under the hood is just going to be compiling and</p>



<p>then telling GDB to launch with the name of my program inside of it.</p>



<p>And then to execute those things.</p>



<p>and then to execute those things.</p>



<p>So it hits breakpoint number 50.</p>



<p>There&#8217;s a bunch of crap that gets printed.</p>



<p>And I can now inspect my registers.</p>



<p>I&#8217;m going to go info R for just info registers.</p>



<p>And let&#8217;s see.</p>



<p>So we had R10, 11, and 12.</p>



<p>So if we look at the terminal, you can see that R10, the hex version,</p>



<p>has the original pattern of the A sequence,</p>



<p>and then R11 has the original pattern of the B sequence.</p>



<p>original pattern of the b sequence if we do a logical and and put the result into r12 then</p>



<p>you should see let me just double check that that&#8217;s definitely r12 yeah then you should see</p>



<p>the result of ending all of the f&#8217;s together remember that an f is just four ones so i&#8217;m kind</p>



<p>of simplifying it a little bit you could make yours more complicated with lots of randomness</p>



<p>in your ones and zeros just to prove it to yourself but notice how r12 only has an f</p>



<p>So like FF means F, F0 means 0, F0 means 0, you know, and so forth.</p>



<p>0F means 0.</p>



<p>So only where you see two Fs will you see an F in the final target pattern.</p>



<p>So that&#8217;s a logical AND, and that&#8217;s how you do it in Yasm Assembly.</p>



<p>You just load up a register with some bits, R12.</p>



<p>We loaded them up with the first pattern.</p>



<p>And then we take the second pattern and say that&#8217;s what I want to AND it against.</p>



<p>that&#8217;s what I want to end it against. And you can have that in a register or I think an immediate</p>



<p>or a memory location. So we&#8217;re just ending these registers together. And you know that they&#8217;re</p>



<p>loaded up with patterns A and B. So nothing too hard at this point. Let&#8217;s do a, let&#8217;s look at</p>



<p>bitwise or this should start on line 52 or I&#8217;m screwing myself. 52. Okay. 52. So same thing,</p>



<p>up R10 and R11 with the bit patterns and then we&#8217;re going to move the first bit pattern</p>



<p>into R12 so that we can or it against the second pattern and so basically R10 and 11</p>



<p>will have the original bit patterns R12 will have the result of oring them.</p>



<p>Then we&#8217;ll do a nope on line 60 so I want to break here on line 60.</p>



<p>Yep I ruined all my line numbers. What did I do wrong? I think I just have it offset by 2 now</p>



<p>two now for some reason so if we just kind of run the program now in the debugger again i&#8217;m going to</p>



<p>quit and then yes if we clear and make debug probably clear was unnecessary we&#8217;re broken at</p>



<p>line 60 if i say info registers the registers in question are oh shoot um 10 11 and 12 right so</p>



<p>we look at 10 and 11 they have the same pattern as before and 12 has a lot more f&#8217;s because if</p>



<p>has a lot more F&#8217;s because if either of the patterns had an F,</p>



<p>then the resulting pattern would have an F.</p>



<p>So this is a logical OR.</p>



<p>Same idea as AND in terms of the way you format the instruction and the OPS,</p>



<p>but it ORs instead of ANDs.</p>



<p>Okay, no problem.</p>



<p>Let&#8217;s move on.</p>



<p>Next thing I want to show you is the XOR, which is pretty cool.</p>



<p>By the way, so far we&#8217;re just operating on bits.</p>



<p>We don&#8217;t consider these bits to actually be numbers.</p>



<p>maybe they are but we should probably be careful about that anyway so I&#8217;m going to say let&#8217;s check</p>



<p>out our bitwise xor which is exclusive or which means exactly one bit in any pair needs to be a</p>



<p>one for the resulting bit to be a one and of course per usual all bits will be checked against each</p>



<p>other in the pair of of bit patterns it&#8217;ll be one bit at a time from each pattern that gets checked</p>



<p>Okay, so it starts on 62 and then we got a nope there.</p>



<p>Okay.</p>



<p>So same thing that we did before.</p>



<p>We&#8217;re just loading up two registers with the bit patterns and then R12 is going to be the</p>



<p>result of exclusive oring or X oring the two bit patterns.</p>



<p>So that means we&#8217;re going to break on line 70.</p>



<p>Now, let me just get rid of my other break point, change that 68 to a 70.</p>



<p>And now I should quit.</p>



<p>bug we&#8217;re at 70 good info registers so I think we said it was 10 and 11 had the original bit patterns</p>



<p>and notice the resulting bit pattern it only has an f in a position where there was exactly</p>



<p>one f between the two input patterns so</p>



<p>wait did I just do something wrong here what did I just do wrong</p>



<p>hang on a second I&#8217;m seeing something bad x or r12 am I looking at r12</p>



<p>Yeah.</p>



<p>R10 and 11.</p>



<p>Did I just do something wrong?</p>



<p>10 and 11 and then we load 10 up into 12 and then we XOR it by 11 and then it stores it</p>



<p>in 12.</p>



<p>Something&#8217;s a little fishy here.</p>



<p>Exactly one.</p>



<p>XOR.</p>



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



<p>Oh, I understand now.</p>



<p>Okay.</p>



<p>So that was a little scary.</p>



<p>This has shifted because the printout is not great.</p>



<p>Because the printout is not great. See how there&#8217;s like a blank space here?</p>



<p>That threw me off. So you have to imagine that all of the bit patterns are kind of shifted.</p>



<p>Maybe I should just copy paste this.</p>



<p>I was worried that I suddenly didn&#8217;t know how to do an XOR in assembly.</p>



<p>So let me get rid of these integers here.</p>



<p>Notice how there&#8217;s just a blank space that shifted everything and threw it off in terms of the display.</p>



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



<p>And what should really happen now is that there should be a zero here.</p>



<p>A zero at the front.</p>



<p>a zero at the front now everything would make more sense sometimes the display likes to just</p>



<p>kind of truncate things and just assume that everything will be read correctly but it wasn&#8217;t</p>



<p>so notice uh in the first position both of the uh both the input patterns are are an f so the</p>



<p>output pattern will be a zero you can imagine under the hood there was a bunch of ones and</p>



<p>then a bunch of ones and that resulted in a bunch of zeros uh here we&#8217;ve got like an f and a zero so</p>



<p>the result is going to be an f and then f and a zero and after zero zero and an f is an f</p>



<p>f um and then where you see zeros that means uh there was not exactly one uh one in each bit</p>



<p>position so for the let&#8217;s say the first one that&#8217;s a bunch of zeros for both input patterns so that&#8217;s</p>



<p>why there&#8217;s a zero there then for the next two each of them had all ones or just the two f&#8217;s</p>



<p>uh so that&#8217;s why x or says it&#8217;s a zero and so forth right so like at the end two f&#8217;s making</p>



<p>Okay, that was a little scary.</p>



<p>I&#8217;m glad I figured that out quickly instead of taking a million years.</p>



<p>Okay.</p>



<p>So now let&#8217;s do another example.</p>



<p>We&#8217;re done with XOR.</p>



<p>Now let&#8217;s look at bitwise knot.</p>



<p>I forgot to explain knot.</p>



<p>I&#8217;m not going to redo this video.</p>



<p>But let me just say that a knot is just inverting the bit.</p>



<p>So if we have a zero, it becomes a one.</p>



<p>And if we have a one, it becomes a zero.</p>



<p>If you knot against a register that has lots of bits or a memory location that has lots</p>



<p>of bits, you can do that and just every single bit in the sequence will just be flipped from</p>



<p>a zero to a one or vice versa.</p>



<p>So let&#8217;s see, we just did bitwise XOR.</p>



<p>Now we&#8217;re going to do a knot starting on line 72, I guess.</p>



<p>And then we&#8217;re going to do another nope there.</p>



<p>Okay.</p>



<p>All right.</p>



<p>So now let&#8217;s get rid of the break point at the line 70 and put it at line 78 instead.</p>



<p>78.</p>



<p>Oh man, this video is going to take forever.</p>



<p>Okay.</p>



<p>So now let&#8217;s check out bitwise knot.</p>



<p>We&#8217;re going to have R10.</p>



<p>Oh, I guess I should improve this because what I&#8217;m doing is I&#8217;m moving everything into</p>



<p>everything into R10 and then I&#8217;m just nodding R10 so we can&#8217;t really compare R10 against itself.</p>



<p>That&#8217;s not fun. Let me instead move R10 into R11 so that I can nod R11 so that we can</p>



<p>see two different registers at least. Okay, so let me just update my solution real fast.</p>



<p>move r11 r10 okay so now it stops at 75 and that one stops at 75 okay cool</p>



<p>now we got our breakpoint should be at line 79 not 78 now we&#8217;re ready to run it and see what the</p>



<p>does clear and make debug info registers so we should have r10 r11 again the formatting is a</p>



<p>so I&#8217;m just going to copy paste it up here. I&#8217;m going to do this, get rid of the numbers,</p>



<p>pad on the left for the missing zeros, and then now you can see clearly that all of the</p>



<p>F&#8217;s were flipped to zero. Again, that means, you know, each F had four ones inside of it,</p>



<p>so all those ones were flipped to a zero, so that&#8217;s why it&#8217;s a zero. Okay, so nodding, pretty easy,</p>



<p>this and show the next example which was gonna be let&#8217;s see seven let&#8217;s check out bitwise rotation</p>



<p>i&#8217;m going to copy paste all the way up to that nope there should start on line 81</p>



<p>i paused before i took a drink of water hopefully i reminded myself later to edit the drink of water</p>



<p>out i don&#8217;t know maybe you&#8217;ll be wondering why my mustache is wet right now if i did not edit it out</p>



<p>I did not edit it out.</p>



<p>Okay, so let&#8217;s check out bitwise rotation.</p>



<p>So I&#8217;m gonna set up R10 and 11 and 12 and 13 and 14,</p>



<p>all with the A pattern.</p>



<p>And then I&#8217;m gonna start rotating things.</p>



<p>So first I&#8217;m gonna rotate to the left R11 and then R12.</p>



<p>I&#8217;m gonna rotate by one position on R11</p>



<p>and then two positions on R12.</p>



<p>And then I&#8217;m going to rotate</p>



<p>rotate by one position for R13 and then two positions for R14 so we should see</p>



<p>some interesting patterns. The NOPE is now on line 94 so I&#8217;m gonna break there</p>



<p>instead whoops so I&#8217;m gonna change that and I&#8217;m now off by three it&#8217;s getting</p>



<p>precarious and then I&#8217;m gonna uncomment all of my little print statements to</p>



<p>show you the value of the registers after I rotate it so we should see like</p>



<p>printed in the terminal just to prove to you what&#8217;s going to happen okay so man I got to</p>



<p>remember what&#8217;s happening now first thing that I did was I printed r10 to show you one type of</p>



<p>rotation and then I printed r10 again to show you another type of rotation so we should see the</p>



<p>original and then the two rotated values and then the original again and then the other two rotated</p>



<p>values so here&#8217;s the original we&#8217;re printing it in binary with the special print command in gdb</p>



<p>in GDB, which is just like P slash T and then the register. So this is the original pattern</p>



<p>right here. And if you just kind of squint at it for a while, you can realize that the dollar</p>



<p>sign two pattern has been, uh, shifted once to the left. Actually, let me just make sure that</p>



<p>I&#8217;m doing a shift and not a rotate. I&#8217;m accidentally saying the word, uh, rotate, I think. And, uh,</p>



<p>that&#8217;s, oh no, no, it is rotate. Yeah. We&#8217;re going to shift later, I guess.</p>



<p>I guess. Okay, so we are definitely rotating. So we should see some wrap around. I guess I used</p>



<p>bad bit patterns for the wrap around. But just imagine that, you know, in this pattern right here,</p>



<p>this one, if we&#8217;re rotating to the left, this one fell off and it got placed on the right side of</p>



<p>of the next pattern it&#8217;s going to be the same thing basically so but this is rotation so we</p>



<p>wouldn&#8217;t be reusing the bits that fell off but anyway you can see that if I rotated to the left</p>



<p>by one position that whole thing is is kind of shifted to the left I shouldn&#8217;t use the word shift</p>



<p>and then for the second pattern we did a rotation by two positions so all the bits are just kind of</p>



<p>moved to the left compared to the very first pattern okay so no problem then the next thing</p>



<p>that we&#8217;re looking at is just you know rotating to the right and you can tell that everything is</p>



<p>offset by one here and it&#8217;s offset by two here so rotating to the left by one position by two</p>



<p>positions rotating to the right by one position or by two positions that&#8217;s rotation in a nutshell</p>



<p>okay so then the next thing that we&#8217;re going to do we&#8217;re on 94 now</p>



<p>um let&#8217;s see logical shifting nope nope nope I&#8217;m gonna grab some code that will shift both</p>



<p>logically and arithmetically so we can kind of see the difference</p>



<p>okay so show maybe I should change this to show some some shifting</p>



<p>because uh if I just say it&#8217;s logical then yeah sure uh the shift function uh the shift</p>



<p>those are logical shifts but then down here when it&#8217;s a sal and sar those are arithmetic shifts</p>



<p>I don&#8217;t know maybe maybe I can do that maybe I can just</p>



<p>duplicate the comment maybe to make it more more intuitive so show arithmetic shifts</p>



<p>Okay, I think that looks pretty good. Let me paste that into 105 on my solution so I don&#8217;t get out of sync here.</p>



<p>So what&#8217;s going to happen here? We&#8217;re basically going to load up R10 with a negative number.</p>



<p>I&#8217;ve chosen the number negative 12 because I kind of feel like it at least shows you a little bit for dividing and stuff like that.</p>



<p>So we&#8217;re loading up R10 with a negative number, and then R11 is going to get R10, but then we&#8217;re going to shift it left by two positions.</p>



<p>positions so that should be multiplying it by four but this is well a bitwise</p>



<p>shifting so it it&#8217;s not going to necessarily respect the fact that the</p>



<p>number is in twos complement so this is not a good idea if you consider r tend</p>



<p>to be a number because sometimes the result might be right and sometimes the</p>



<p>result might be wrong here it says math won&#8217;t work in my comment but sometimes</p>



<p>it will accidentally work but you still want to consider it to be non-working</p>



<p>It&#8217;s only good for bit shifting.</p>



<p>Then we&#8217;re going to put R12, we&#8217;re going to give it the same value as R10 and then we&#8217;re</p>



<p>just going to shift it to the right by two positions.</p>



<p>This will definitely break because when you shift to the right, the sine bit is going</p>



<p>to get padded with a zero rather than what the actual sine bit was originally.</p>



<p>So that will almost certainly break it almost every time.</p>



<p>Then we&#8217;re going to use arithmetic shifts which just respect the fact that the original</p>



<p>number is two&#8217;s complement.</p>



<p>two&#8217;s complement so you know like we have this negative 12 number it&#8217;s going to end up being</p>



<p>bits but the uh the shl and the shr instructions are not going to respect the fact that it&#8217;s</p>



<p>negative 12 they&#8217;re just going to consider them to be bits but the sal shifting to the left</p>



<p>arithmetically and the sar shifting to the right arithmetically are going to respect that respect</p>



<p>the fact that it&#8217;s two&#8217;s complement so let&#8217;s see we&#8217;ve got all this stuff and then we&#8217;ve got a</p>



<p>We&#8217;ve got all this stuff and then we&#8217;ve got a non-operation here.</p>



<p>You know, again, like per usual, when we&#8217;re shifting, when we&#8217;re rotating, when we&#8217;re</p>



<p>oaring, anding, whatever, it&#8217;s just the instruction name followed by both the source and the</p>



<p>destination operand.</p>



<p>And then the second operand is only going to be source.</p>



<p>So if we have a shifting left R11, then the result is going to be stored in R11, but it&#8217;s</p>



<p>going to take as the source R11 and shift it to the left by two positions.</p>



<p>to the left by two positions and so forth.</p>



<p>Okay.</p>



<p>So we have all of that.</p>



<p>We&#8217;re going to nope on line one of what is it?</p>



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



<p>So that means I&#8217;m going to stop breaking on 94 and I&#8217;m going to break on one 14.</p>



<p>I thought it was four lines off and now I&#8217;m only two lines off.</p>



<p>I think I just did something else wrong here between my source.</p>



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



<p>Is the nope on one 14 up there?</p>



<p>Yeah, it is.</p>



<p>Okay.</p>



<p>Guess I didn&#8217;t do that much wrong.</p>



<p>Okay.</p>



<p>Okay, so let&#8217;s run this, but this code up here was just going to print bit patterns</p>



<p>related to our rotations.</p>



<p>I don&#8217;t really want that anymore.</p>



<p>So I&#8217;m going to uncomment all of these other prints that relate to our shifts.</p>



<p>And this is going to be a nightmare to read and interpret, but I&#8217;m going to try.</p>



<p>I really should have written a more complicated program that can just print them in the terminal</p>



<p>so I don&#8217;t have to like read the debugger.</p>



<p>Whatever, it&#8217;s brain exercise.</p>



<p>size. And I think this actually is the end of the program. 119 is the last line. Yeah. Okay.</p>



<p>So we just need to run this and see what happens. So really we&#8217;re interested in these, uh, you know,</p>



<p>shifting to the left twice, shifting to the right twice bit wise, and then shifting to the left</p>



<p>twice, arithmetically shifting to the right twice, arithmetically. Okay. So we&#8217;ll go back to the</p>



<p>terminal here and quit. And then I&#8217;m going to do make debug. And now there&#8217;s a bunch of junk.</p>



<p>here&#8217;s the original number and then we&#8217;re gonna bitwise shift left binary</p>



<p>notice how it just sort of you know it shifted everything to the left and you</p>



<p>know we&#8217;re not using we&#8217;re not printing hex anymore because I want you to see</p>



<p>the binary and then you know like the patterns are just shifted to to the left</p>



<p>like see here&#8217;s the first one if we&#8217;re looking at the right side and then here</p>



<p>is the first one if we&#8217;re looking at the right side for the shifted version</p>



<p>A similar deal for shift right except we lost a couple of numbers there because of the display</p>



<p>so I&#8217;m going to copy paste both of these real fast.</p>



<p>Per usual we lost numbers due to the display so I&#8217;m going to say notice how we have two</p>



<p>numbers missing here if I added zeros on the right side that&#8217;s going to change the actual</p>



<p>value so I&#8217;m going to have to add them to the left and now we can clearly see that the</p>



<p>shifted four positions I think to the left wait did I do that where did I where did I even just</p>



<p>copy paste from original shift left and shift right okay so shift right is what it&#8217;s supposed</p>



<p>to be doing let me just double check here shift right is printing r12 and what does r12 have it</p>



<p>shifting right by two. Okay.</p>



<p>Oh, I&#8217;m supposed to compare it to the very first one.</p>



<p>Let me just double check that I have this correct now.</p>



<p>Why is it</p>



<p>shifting to the right? Oh gosh, I think I just lost track of myself. Let me just,</p>



<p>give me a second here. Or 14.</p>



<p>I&#8217;m forgetting where I copy and paste. Okay. Bitwise shift right is</p>



<p>bitwise shift right is R12, not R14. Oh gosh. Did I do it wrong? Were you cringing at home?</p>



<p>Maybe this will work. And the two, that&#8217;s kind of the same thing that I did before. No, no,</p>



<p>it&#8217;s different. Okay. So I had it wrong before. Now I finally have it right. So you can see that</p>



<p>So you can see that the bit pattern is shifted twice to the right and then on the left two zeros show up which would have destroyed a number.</p>



<p>Okay.</p>



<p>So we shift it to the right and now we&#8217;re ready to look at arithmetic shift to the left and right.</p>



<p>And let&#8217;s see do we have enough bits to actually print everything?</p>



<p>This one should look like it&#8217;s shifted to the right just because of the way it prints.</p>



<p>So that means this one is totally lined up.</p>



<p>Okay so let me grab the original pattern here.</p>



<p>grab the original pattern here so this is the original pattern and then if I go shift left</p>



<p>in binary I&#8217;ll just put an L here and then I&#8217;ll put shift right in binary</p>



<p>there we have enough bits I think in both cases so we don&#8217;t have to pad</p>



<p>so now if we look at the original pattern and then we shift left arithmetically twice</p>



<p>twice notice how it does kind of look like it survived right like this one moved over to the</p>



<p>left twice because the sine bits are just kind of falling off but there&#8217;s enough of them that it&#8217;s</p>



<p>not going to change the sine bit thank you two&#8217;s complement but when we shift to the right</p>



<p>arithmetically normally we would have padded on the left with zeros remember we had zeros there</p>



<p>on the left before but now that we&#8217;re respecting the arithmetic uh the the padding is correct now</p>



<p>is correct now for two&#8217;s complement so that&#8217;s why there are ones there instead of zeros</p>



<p>and then if you kind of look at it it&#8217;s like well we shifted twice to the right let me get</p>



<p>rid of the left because we already understand that now it seems to be that the pattern is uh</p>



<p>every bit is shifted over to the right the correct number of times the zeros dropped off the side</p>



<p>and um the sine bits were padded on the left so everything seems to be correct and then just to</p>



<p>to kind of prove to you that what we&#8217;re seeing is real, I just have the same things printed</p>



<p>all over again from scratch in decimal. So originally we had our R10 as negative 12.</p>



<p>And then if we do a bitwise shift to the left, it multiplies it by four. And so we&#8217;re accidentally</p>



<p>correct here. Remember, this is a bitwise shift, so it doesn&#8217;t respect two&#8217;s complement. So just,</p>



<p>we happen to have a starting number that would end up looking correct after we shifted it to the left.</p>



<p>And then when we do a bitwise shift to the right, again, this could be disaster because we&#8217;re not</p>



<p>respecting two&#8217;s complement or the sine bit. And that&#8217;s exactly what happened. You know, definitely</p>



<p>if we&#8217;re shifting to the right, that should be 12 divided by four equals three or negative three.</p>



<p>But instead we get this gigantic huge number because the sine bit got killed with the zeros</p>



<p>killed with the zeros that were padded on the left. And then we finally try to shift left</p>



<p>arithmetically. We end up still with negative 48, which is the correct number. If we&#8217;re going to</p>



<p>shift left twice, that&#8217;s multiplying 12 by 4 and that&#8217;s 48 or negative 48. And then when we shift</p>



<p>to the right, that should divide it by 2 twice because we&#8217;re shifting to the right by two</p>



<p>positions. So that should be 12 divided by 4, which is negative 3 or sorry, negative 12 divided</p>



<p>which is negative three so everything seems to be working except for a couple of moments of</p>



<p>stumbling on my part which i hope you laughed at um and i think this is the end of the program so</p>



<p>now hopefully you&#8217;re an expert in uh ending oring x oring nodding shifting left and right uh bitwise</p>



<p>rotating. We&#8217;ve done it all in this one video. How long did this video take? 40 minutes?</p>



<p>Anyway, thank you so much for watching this video. I hope you learned a little bit of stuff</p>



<p>and you had a little bit of fun. I&#8217;ll see you in the next video.</p>



<p>Hey everybody, thanks for watching this video again from the bottom of my heart. I really</p>



<p>appreciate it. I do hope you did learn something and have some fun. If you could do me a please,</p>



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



<p>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 me a kindness</p>



<p>and subscribe. You know, sometimes I&#8217;m sleeping in the middle of the night and I just wake up</p>



<p>because I know somebody subscribed or followed. It just wakes me up and I get filled with joy.</p>



<p>just wakes me up and I get filled with joy. That&#8217;s exactly what happens every</p>



<p>single time. So you could do it as a nice favor to me or you could you could</p>



<p>troll me if you want to just wake me up in the middle of the night just subscribe</p>



<p>and then I&#8217;ll just wake up. I promise that&#8217;s what will happen. Also if you look</p>



<p>at the middle of the screen right now you should see a QR code which you can</p>



<p>scan in order to go to the website which I think is also named somewhere at the</p>



<p>bottom of this video and it&#8217;ll take you to my main website where you can just</p>



<p>kind of like see all the videos I published and the services and tutorials</p>



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



<p>If you have a suggestion for</p>



<p>Clarifications or errata or just future videos that you want to see</p>



<p>Please leave a comment 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. I also wake up for those in the middle of the night</p>



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



<p>It would really it really mean the world to me. I would really appreciate it. So</p>



<p>Again, thank you so much for watching this video and enjoy 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/x86-64-assembly-bit-manipulation-and-or-xor-not-shifts-rotates-tutorial/">x86-64 Assembly Bit Manipulation: AND, OR, XOR, NOT, Shifts &amp; Rotates Tutorial</a> appeared first on <a href="https://www.NeuralLantern.com">NeuralLantern.com</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://www.NeuralLantern.com/x86-64-assembly-bit-manipulation-and-or-xor-not-shifts-rotates-tutorial/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>Master Two&#8217;s Complement: Convert &#038; Subtract Negative Binary Numbers</title>
		<link>https://www.NeuralLantern.com/master-twos-complement-convert-subtract-negative-binary-numbers/</link>
					<comments>https://www.NeuralLantern.com/master-twos-complement-convert-subtract-negative-binary-numbers/#respond</comments>
		
		<dc:creator><![CDATA[mike]]></dc:creator>
		<pubDate>Sun, 18 May 2025 22:53:54 +0000</pubDate>
				<category><![CDATA[Computer Science]]></category>
		<category><![CDATA[Conversions]]></category>
		<category><![CDATA[Videos]]></category>
		<category><![CDATA[binary conversion]]></category>
		<category><![CDATA[binary math]]></category>
		<category><![CDATA[binary numbers]]></category>
		<category><![CDATA[binary subtraction]]></category>
		<category><![CDATA[coding for beginners]]></category>
		<category><![CDATA[computer science basics]]></category>
		<category><![CDATA[negative numbers binary]]></category>
		<category><![CDATA[programming tutorials]]></category>
		<category><![CDATA[signed integers]]></category>
		<category><![CDATA[two's complement]]></category>
		<guid isPermaLink="false">https://www.NeuralLantern.com/?p=110</guid>

					<description><![CDATA[<p>Learn two's complement to represent negative binary numbers with easy examples. Master sign bits &#038; subtraction. Subscribe!</p>
<p>The post <a href="https://www.NeuralLantern.com/master-twos-complement-convert-subtract-negative-binary-numbers/">Master Two&#8217;s Complement: Convert &amp; Subtract Negative Binary Numbers</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 Two&#039;s Complement: Convert &amp; Subtract Negative Binary Numbers" width="1380" height="776" src="https://www.youtube.com/embed/i2tfzMqlewQ?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 conquer negative numbers in binary? This fun, beginner-friendly tutorial breaks down two&#8217;s complement with step-by-step examples (-109, -29) and shows how to convert, pad, and subtract in binary. Learn sign bits, carry bits, and avoid common mistakes. Subscribe for more coding tips and tech tutorials that make learning a blast! Scan the QR code for more resources and join our community!</p>



<p>Introduction to Two&#8217;s Complement 00:00:00<br>Signed vs. Unsigned Integers 00:00:28<br>Sign Bit Explanation 00:01:55<br>Positive and Negative Representation 00:02:06<br>Range of Signed Integers 00:02:48<br>Padding Signed Integers 00:05:36<br>Converting to Negative (Example: -109) 00:07:00<br>Binary Addition and Carry Bits 00:10:16<br>Correcting Conversion Mistakes 00:16:38<br>Converting Negative 29 00:13:32<br>Subtraction Using Two&#8217;s Complement 00:18:21<br>Adding Binary Numbers (109 &#8211; 29) 00:20:41<br>Verifying Results 00:23:56<br>Conclusion and Call to Action 00:25:40</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 there! Let&#8217;s talk about representing negative numbers in binary.</p>



<p>We&#8217;re going to use a system called 2&#8217;s complement which is going to allow us to represent signed integers,</p>



<p>which means there will be a positive sign or a negative sign on the integer</p>



<p>and we&#8217;ll still be able to do it in pure binary.</p>



<p>So let me talk a little bit about what I mean first here.</p>



<p>signed and unsigned okay so if i just type the number 14 by itself that is uh that&#8217;s an unsigned</p>



<p>integer we don&#8217;t really know if it&#8217;s positive or negative like do we know that it&#8217;s negative 14 or</p>



<p>do we know that it&#8217;s positive 14 right so the sign is what lets us know if something is positive or</p>



<p>negative okay so if i if i type a number in binary let&#8217;s just do a pure binary number one two three</p>



<p>if you know how to convert binary to decimal you probably recognize right away that this is just</p>



<p>the number zero even if we add a couple of bits here that&#8217;s just like the number three</p>



<p>and so this is the number three but so far if if you haven&#8217;t learned signed integers in twos</p>



<p>complement or in binary then you don&#8217;t really know that there&#8217;s a sign you just kind of assume</p>



<p>that the number is positive by default if you&#8217;re not using twos complement and you&#8217;re just saying</p>



<p>and you&#8217;re just saying like well let&#8217;s just do a bunch of binary you know digits then yeah it&#8217;s a</p>



<p>safe assumption that the the sign is positive but we&#8217;ll use two&#8217;s complement which starts with the</p>



<p>idea that the highest bit the leftmost bit the bit with the height you know the most power that&#8217;s</p>



<p>going to turn into the sign that&#8217;s that&#8217;s going to turn into the plus or the minus so like you</p>



<p>the sign.</p>



<p>So this means that we have to decide, you know, does a zero mean positive or does it</p>



<p>mean negative or what means what?</p>



<p>So in two&#8217;s complement, we&#8217;ll say that zero is positive and one is negative.</p>



<p>So you can see right here that we&#8217;re still actually representing the number three, but</p>



<p>it&#8217;s positive three for sure because this sign bit right here is zero.</p>



<p>That&#8217;s positive.</p>



<p>Once we decide to represent two&#8217;s complement, then we can say that for sure.</p>



<p>On the other hand, if we put a one here,</p>



<p>then we definitely know that this number is now negative.</p>



<p>However, we don&#8217;t actually know that it&#8217;s a three</p>



<p>because the numbers don&#8217;t work out the same anymore</p>



<p>in two&#8217;s complement.</p>



<p>So the positive numbers, they will mostly look the same.</p>



<p>The negative numbers, they&#8217;ll look a lot different,</p>



<p>but they&#8217;ll still be valid in order,</p>



<p>you know, in terms of us being able to add them together,</p>



<p>subtract them from each other and things like that.</p>



<p>So two&#8217;s complement is pretty cool.</p>



<p>Let&#8217;s do, let&#8217;s see, what else can I tell you?</p>



<p>Oh, one thing to understand is that</p>



<p>One thing to understand is that in an 8-bit unsigned integer in binary, let&#8217;s say 1, 2,</p>



<p>3, 4, 5, 6, 7, 8, let&#8217;s say unsigned bits, maybe I&#8217;ll just put like, maybe just some</p>



<p>like V for value, all the bits are values, that means the range is 0 to 255 with 256</p>



<p>total combinations.</p>



<p>But if we want to use a signed number, then we&#8217;ll actually have the signed bit be the first bit,</p>



<p>and all the rest will be value bits.</p>



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



<p>In this case, the range kind of goes down.</p>



<p>Because if you think about it, every single bit, you know, represents like, you know,</p>



<p>it helps towards the highest possible value that you can represent.</p>



<p>If we&#8217;re using the leftmost bit, then for an 8-bit integer, that&#8217;s 128.</p>



<p>integer that&#8217;s 128 that&#8217;s a value of 128 so we lose a lot off of the maximum</p>



<p>integer that we can represent so the range here is I think it&#8217;s negative 20</p>



<p>128 to positive 127 just keep in mind you&#8217;ll have to trust me in terms of why</p>



<p>is the negative 128 bigger and the positive 127 you know smaller but that&#8217;s</p>



<p>just the way it is so that means we only get these value bits here and if you if</p>



<p>that um let&#8217;s see if i can do this quickly enough without screwing it up we&#8217;ll say 127 minus um</p>



<p>minus negative 128 i guess that&#8217;s 255 and then also a zero but uh in terms of positive and</p>



<p>negative the way this is going to work out is the zero will probably show up twice because uh</p>



<p>255 possible combinations with seven bits.</p>



<p>Normally you would have a range from negative, sorry, from zero to positive 255.</p>



<p>And in this case, we&#8217;re just, you know, losing our range, but we can represent negative numbers.</p>



<p>Anyway. Okay.</p>



<p>So let&#8217;s talk about doing an example real fast. Let&#8217;s see.</p>



<p>I&#8217;ve got like a little notes to tell me what I should do. Okay.</p>



<p>It&#8217;s important to understand that normally when you have, let&#8217;s say, let&#8217;s say you have</p>



<p>like an 8-bit number and you go 1, 2, 3, 4, 5, 6, 7, 8.</p>



<p>And then you have 2 bits right there and so this is like, you know, positive 3.</p>



<p>If you wanted to copy that number into more bytes, like for example, if you wanted to</p>



<p>take a 2-byte integer and have it copy the value of a 1-byte integer, then it&#8217;s pretty</p>



<p>easy.</p>



<p>zeros to the left you&#8217;ll say one two three four five six seven eight that would work perfectly</p>



<p>however if you did this with a negative number let&#8217;s say that we have a negative number</p>



<p>I&#8217;m going to put some of the random patterns so that you don&#8217;t think it&#8217;s the three let&#8217;s see</p>



<p>one two three four five six seven eight that&#8217;s eight total so I&#8217;m going to make that a one and</p>



<p>then get rid of that so we have like eight negative number if we were going to copy that</p>



<p>integer then we would copy paste it to start but then you&#8217;d have to pad with</p>



<p>ones to the left one two three four five six seven eight same negative number</p>



<p>more bits so be very careful about how you pad if you&#8217;re padding an unsigned</p>



<p>integer then yeah you&#8217;ll always pad zeros to the left no matter what is</p>



<p>happening but if you&#8217;re padding a signed integer then you have to pad differently</p>



<p>signed integer you have to pad with whatever the highest bit is so in this case the highest bit was</p>



<p>a zero so we do pad with zeros but then in this case the highest bit was a one so we have to pad</p>



<p>with ones if you don&#8217;t do that you&#8217;re going to end up with a number that doesn&#8217;t actually make</p>



<p>sense okay so now let&#8217;s work on actually converting a number to a negative number or representing a</p>



<p>negative number in twos compliment okay so i&#8217;m going to write twos compliment here and then uh</p>



<p>Let&#8217;s start off with the number negative 109.</p>



<p>Okay, how do we do this?</p>



<p>The first thing is convert it to its positive form.</p>



<p>Take the absolute value. Okay.</p>



<p>So we&#8217;re really just, you know, take positive form here,</p>



<p>and that&#8217;s just going to be positive 109.</p>



<p>Okay, no problem.</p>



<p>I&#8217;ll say start with negative 109, and then we&#8217;ll take the positive form 109.</p>



<p>Now we&#8217;ll convert it to binary.</p>



<p>Okay, this is not a video that teaches you how to convert to binary, so I&#8217;m just going</p>



<p>to try to do this in my head real fast here.</p>



<p>It&#8217;s going to be, let&#8217;s see, we got 8 bits, we&#8217;ll use just 8 bits to store the number,</p>



<p>and because it&#8217;s low enough and I don&#8217;t want to use that many bits, so it&#8217;s odd, so I can</p>



<p>add a 1 there, but maybe for now I should find the highest bit that is less than the</p>



<p>actual number.</p>



<p>So this is the 128 bit right here. So that&#8217;s going to be a zero. This is the 64 bits</p>



<p>I&#8217;m going to put a one there and I&#8217;m just going to say</p>



<p>Mmm, maybe like</p>



<p>This is like maybe not the smartest way to do it. I&#8217;ll say 109 minus 64</p>



<p>Because I put a one there and then 45 so now this is 32 that&#8217;s less than 45. So I&#8217;ll put a one there and</p>



<p>Then it&#8217;s going to be minus 40</p>



<p>So it goes from 45 to 13.</p>



<p>So then that was the 32.</p>



<p>Okay, so 128, 64, 32, and then 16.</p>



<p>Is 16 less than 13?</p>



<p>No, it&#8217;s not.</p>



<p>So we&#8217;ll put a zero here.</p>



<p>And then the next one is going to be just four.</p>



<p>Four is definitely less.</p>



<p>So I&#8217;ll put a one bit there.</p>



<p>And then I&#8217;ll subtract four.</p>



<p>And then one, two, four.</p>



<p>Oh, wait a minute.</p>



<p>One, two, four, eight.</p>



<p>wait a minute one two four eight sorry that was supposed to be subtracted uh subtracting eight</p>



<p>because that was the eight bit uh then i want to get five so here is the four bit so i put a one</p>



<p>there and then i&#8217;ll just put a one here because four plus five is equal to uh i&#8217;m sorry four plus</p>



<p>one is equal to five so let&#8217;s see um it is let me just double check here one</p>



<p>one let me just double check my conversion real fast it&#8217;s going to be</p>



<p>the one bit plus two four plus eight six thirty two plus thirty two plus sixty</p>



<p>four did I get one on nine yeah okay so I guess I did it right so convert to</p>



<p>binary and that&#8217;s going to be this the next thing we&#8217;ll do is we will invert the</p>



<p>bits I made a little edit jump here because I inverted the bits incorrectly</p>



<p>on the first try which is sad but hey it happens the next thing we&#8217;ll do is</p>



<p>but hey it happens the next thing we&#8217;ll do is we&#8217;ll invert the bits so basically you know we</p>



<p>take this original sequence here and i&#8217;ll just turn every single bit uh i&#8217;ll flip it i&#8217;ll flip</p>



<p>ones to zeros and zeros to ones so i&#8217;m going to go one zero zero one zero zero one zero okay so now</p>



<p>we have this number invert the bits then we just have to add one so we&#8217;ll add positive one to that</p>



<p>that it&#8217;s just going to be a one there at the end.</p>



<p>But sometimes that might not be the case</p>



<p>because what if we already had a one there</p>



<p>and we had to add one to that?</p>



<p>Well, we&#8217;d add one to the right side</p>



<p>and it would turn into a zero</p>



<p>and then it would carry a bit to the left.</p>



<p>That would become a zero</p>



<p>and then the carry bit would show up all the way over there.</p>



<p>So I just want you to be aware of the fact that</p>



<p>when you add two binary numbers together,</p>



<p>you have to be careful.</p>



<p>You have to add them the same way you would add decimal numbers.</p>



<p>For each digit&#8217;s position,</p>



<p>you have to add the two numbers together and then if they overflow then you just</p>



<p>kind of wrap around to the lowest number again subtracting you know the highest</p>



<p>value or sorry subtracting the base like in decimal if you add 9 and 9 the answer</p>



<p>is 18 but you&#8217;re not going to write 18 in that one position you&#8217;re going to</p>



<p>subtract the base which is 10 so it&#8217;ll actually be 8 and then you&#8217;ll carry the</p>



<p>plus nine is equal to eight carry the one right so we&#8217;ll do the same thing in binary we&#8217;ll say</p>



<p>if we ever get a one plus one when we&#8217;re adding the answer will be two but then we subtract the</p>



<p>base which is two so the answer is actually zero carry a one bit keep that in mind i&#8217;m just gonna</p>



<p>write it all out for you so you can kind of get a little bit of practice it&#8217;s important to to</p>



<p>practice this because it&#8217;s easy to get wrong i&#8217;m going to put a bunch of dashes up at the top to</p>



<p>and I&#8217;m going to say we&#8217;re going to add, you know, one number plus another number,</p>



<p>put a little plus symbol over there just to try and make sure we do it the right way.</p>



<p>Okay, so how do we add these?</p>



<p>Well, we&#8217;ll just go to the right side.</p>



<p>Zero plus one is one, no carry bit.</p>



<p>One plus zero is one, no carry bit.</p>



<p>Then we got a couple zeros here, no carry bit, of course.</p>



<p>One plus zero is one, no carry bit.</p>



<p>And then a couple zeros and then another one with no carry bit.</p>



<p>Okay, so, you know, we could have done that pretty easily, but</p>



<p>but well now we&#8217;re getting a taste for binary addition that might be harder later.</p>



<p>So we&#8217;ll just do that for now.</p>



<p>And now this is the two&#8217;s complement representation of negative 109.</p>



<p>I&#8217;ll say now we have negative 109 is equal to that.</p>



<p>leftmost number the most powerful sorry leftmost bit the most powerful bit is a one remember one</p>



<p>always indicates negative so when you&#8217;re looking at it if your leftmost bit turns out to be a zero</p>



<p>then you probably did something wrong or you had an overflow maybe um and again if we were going</p>



<p>to try to you know send this number into a two byte number or an eight byte number or whatever</p>



<p>uh then we would just have to pad with the sign bit so one two three four five six seven eight</p>



<p>help my brain so this was this is the way it would look in a two-byte number this is the way it would</p>



<p>look in a three-byte a four-byte and five six seven how many one two three four five six seven</p>



<p>okay one more this is what it would look like as an eight-byte number or a quad word 64-bit number</p>



<p>yeah okay so now we know how to do negative 109 okay so now let&#8217;s do a number that&#8217;s a little bit</p>



<p>negative 29. So let&#8217;s say convert, or how about represent negative 29 into</p>



<p>2&#8217;s complement. Okay. So first we, you know, first get the absolute value.</p>



<p>So just 29. And then we have to invert the, sorry, we have to get that into binary. So</p>



<p>next convert to binary. And I&#8217;m going to start with zeros, one, two, three, four, five, six,</p>



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



<p>For this video, remember, we&#8217;re choosing to use one byte integers.</p>



<p>But if you wanted to do a bigger one or you had to do a bigger one,</p>



<p>then just, you know, keep that in mind.</p>



<p>Okay, so 128 is not smaller than 29.</p>



<p>64 is not.</p>



<p>32 is not.</p>



<p>16 is, though.</p>



<p>So I&#8217;ll put a 16 bit there.</p>



<p>And I&#8217;ll just subtract 16 from 29.</p>



<p>29 minus 16.</p>



<p>Now we&#8217;ve got 13 left.</p>



<p>So 64, 32, 16.</p>



<p>six four thirty two sixteen eight okay so now I&#8217;m gonna put a one bit there and</p>



<p>I&#8217;m gonna subtract 8 from the remainder and then we got a five which is pretty</p>



<p>easy to do eight four and then a one so now we have well zero zero zero one one</p>



<p>one zero one that&#8217;s the binary number the positive or unsigned representation</p>



<p>representation. So now we&#8217;ll add one. Positive one. And let&#8217;s try to do this the right way so</p>



<p>that we can practice carry bits with addition a little bit. Notice how this one is already there</p>



<p>on the right side. So it&#8217;s going to, we&#8217;re going to have at least one carry bit for sure.</p>



<p>So then I&#8217;m going to go doop like that. And then I&#8217;m going to say that we have like, you know,</p>



<p>what is the result? Put a positive sign there. And then I&#8217;m going to put a bunch of dashes</p>



<p>my carry bits because I can I can forget that pretty easily. So the first thing is we add one</p>



<p>and one. The answer is two, but we can&#8217;t put the number two here because it&#8217;s binary. Instead we</p>



<p>need to subtract the base which is two. So two minus two is equal to zero, but then we have a</p>



<p>carry bit of one. So I&#8217;m going to put a one there. The first carry bit will stay as a dash for this</p>



<p>whole you know exercise because you&#8217;re not going to carry on to the first digit. So now we have</p>



<p>what would have been just zero plus zero now we have one plus zero plus zero so</p>



<p>that means this is going to be one and then the carry bit is just going to be</p>



<p>zero because we don&#8217;t actually carry anything so then we have zero plus one</p>



<p>plus zero so that&#8217;s going to be a one and then zero carry bit and then zero</p>



<p>one zero is just going to be one and then there&#8217;s going to be no carry bit</p>



<p>and then zero one zero again a one no carry bit because we didn&#8217;t actually</p>



<p>zero zero zero and then I&#8217;m just gonna put zeros here okay so now we have</p>



<p>successfully added I blew it totally blew it I always forget steps don&#8217;t</p>



<p>forget the steps this is a good lesson I&#8217;m gonna leave this in the video</p>



<p>because I want you to see that everybody makes mistakes and you got to practice</p>



<p>practice practice especially before you have to actually do this in real life or</p>



<p>or something like that.</p>



<p>Next, convert to binary.</p>



<p>Before you add one, I&#8217;m gonna just remove this.</p>



<p>Oh my gosh.</p>



<p>Next, flip the bits,</p>



<p>which is gonna be 1110010.</p>



<p>Okay.</p>



<p>So now we take this bit flipped number</p>



<p>and we will add one.</p>



<p>So that&#8217;s gonna be zero, zero, zero, zero, zero, zero, zero,</p>



<p>one, oh, it&#8217;s too easy.</p>



<p>Maybe I got excited and I thought,</p>



<p>excited and I thought, oh, it&#8217;s carry bit time.</p>



<p>But even though the last edition that I did was wrong because I forgot to carry</p>



<p>the or flip the bits, you still at least saw a little bit about how to carry the bits.</p>



<p>Right. OK, so it&#8217;s just going to be one.</p>



<p>Let me start from the right side.</p>



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



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



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



<p>OK, so I got that.</p>



<p>Now we have.</p>



<p>negative 29 in twos compliment. Again notice if we actually tried to add those numbers up to be</p>



<p>like an unsigned binary number they&#8217;re not really going to make sense because this is like 64 plus</p>



<p>32 plus 3. So what would that end up being? Let&#8217;s just double check here. 64 plus 32 plus 3, 99.</p>



<p>That&#8217;s not actually the number but the number is 29. So keep in mind you can&#8217;t just look at this</p>



<p>unless you&#8217;re like really, really practiced.</p>



<p>Okay, and again, notice that the number is 1 at the very left,</p>



<p>indicating that it&#8217;s a negative number.</p>



<p>Now, let&#8217;s look at how to subtract one number from another</p>



<p>using 2&#8217;s complement.</p>



<p>Okay, so what I want to do is I want to subtract,</p>



<p>let&#8217;s say, 29 from 109.</p>



<p>Okay, so let&#8217;s subtract, and I&#8217;ll just say 109 minus 29.</p>



<p>109 minus 29.</p>



<p>And how I would do that is basically I&#8217;ll start by just taking 109.</p>



<p>Let&#8217;s see, convert to binary.</p>



<p>So I&#8217;m just going to copy paste that number.</p>



<p>So 109 is this and then 29, take the positive version.</p>



<p>It is just, let&#8217;s see, before we flip the bits or anything,</p>



<p>let me make sure that I grab the right one.</p>



<p>Invert the bits, okay.</p>



<p>So positive 29 is this number.</p>



<p>Whoops.</p>



<p>is this number whoops let me put parentheses around that so it&#8217;s easy to tell and then I&#8217;ll</p>



<p>put a positive sign there like that maybe like that nope nope nope nope how about this okay</p>



<p>so now we have both of these numbers in positive form so now if we added 109 plus 29 that wouldn&#8217;t</p>



<p>negative positive 29 that would be what we wanted right because really if you&#8217;re subtracting</p>



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



<p>positive 29 plus negative 29 all we really need to do is um invert the 29 and then add the result</p>



<p>to 109 so that means we&#8217;ll we&#8217;ll turn positive 29 into negative 29 using two&#8217;s complement</p>



<p>through the steps again but basically put it there but basically you know that&#8217;s negative 29</p>



<p>so say positive 129 is equal to what i just put up here and then negative 29 is equal to</p>



<p>maybe i should do the parentheses again for clarity uh is equal to this okay so you can tell</p>



<p>that positive 29 is pretty pretty different from negative 29 but now we have</p>



<p>29 but now we have both of those numbers so let&#8217;s see 0 1 1 0 and then we&#8217;re ready to add okay all</p>



<p>we got to do is add them together next add them together maybe I should write the steps up here</p>



<p>negative 29 using twos complement and then next add them together so then I&#8217;m</p>



<p>going to copy paste the bits here and it&#8217;s going to be this plus this do a</p>



<p>positive plus sign just to remind ourselves that we are actually adding</p>



<p>and then I&#8217;m going to put a bunch of placeholders for sign bits up at the</p>



<p>top and now we&#8217;ll have a little bit more fun adding numbers together maybe I&#8217;ll</p>



<p>drag this down</p>



<p>Oh my god. Oh, there we go. Okay. So I&#8217;ll start with the one on the right, the position on the</p>



<p>right. That&#8217;s going to be one plus one equals two, but then that&#8217;s an overflow. So I&#8217;m going to</p>



<p>subtract the base. So it&#8217;s going to be zero. And then don&#8217;t forget to carry the one. Oh,</p>



<p>cool. More interesting. So we have one plus zero plus one. That&#8217;s going to be another two carry</p>



<p>two carry the one so it&#8217;s going to be zero and then carry the one again so i&#8217;m going to put the</p>



<p>carry bit up there and then again we have one plus one is equal to two so it&#8217;s going to be zero</p>



<p>carry the one again zero carry the one and then finally we don&#8217;t really have a carry bit</p>



<p>um so we&#8217;ll just have like a one and there&#8217;s there&#8217;s no carry so it&#8217;s going to be you know</p>



<p>carry a zero and then we add these two together so it&#8217;s going to be a zero carry the one and then</p>



<p>Now we have a three.</p>



<p>Oh, that&#8217;s kind of nice.</p>



<p>So this is an interesting edge case kind of.</p>



<p>One plus one plus one is three.</p>



<p>But if we subtract two, the base from it, you know, three minus two, it&#8217;s going to be one, not zero.</p>



<p>So it actually is going to be a one and then carry the one on top of that.</p>



<p>Then for here, let me space this over a little bit so that I can illustrate what&#8217;s going on a little bit better.</p>



<p>We&#8217;re going to have one plus zero plus one.</p>



<p>definitely going to be zero and then carry the one but there&#8217;s no bit where that carried one can</p>



<p>can show up on right so that one overflows it falls off the edge if this was a bigger number</p>



<p>then okay we you know if we had more bits to this number then sure we would just keep carrying over</p>



<p>over to the left but remember we said before that when we have a very big number let&#8217;s see</p>



<p>bits it&#8217;s just ones all the way to the side that will actually help us make sure that if our final</p>



<p>number is actually going to end up being positive that everything kind of like dominoes like carry</p>



<p>the one carry the one carry the one carry the one carry the one all the way until one of the ones</p>



<p>falls off think about it so anyway this one just is gone we don&#8217;t really care about it anymore</p>



<p>the result is going to be just only eight bits because that&#8217;s the number that we started with</p>



<p>bunch of zeros what is you know the final answer let&#8217;s just compute this</p>



<p>real fast to decimal so this is 128 and then 64 so it&#8217;s gonna be 64 plus not 32</p>



<p>but 16 so 64 plus 16 that&#8217;s gonna be oops 16 that&#8217;s gonna be 80 and now we</p>



<p>just have to ask ourselves again as like a final step to double check yourself to</p>



<p>what you&#8217;re doing and that you got it right is just punch up 109 minus 29 just to make sure</p>



<p>109 minus 29 whoops what happened here 109 minus</p>



<p>oh i think i stole my subtraction key for the annotator 109 minus 29 is 80</p>



<p>so again you know if you&#8217;re if you&#8217;re trying to like you know write something down to do some</p>



<p>you know taking an exam or something you definitely want to double check yourself in several ways</p>



<p>As you can tell from this video alone</p>



<p>I got one of these things wrong because I forgot to input the bits as a step before adding one</p>



<p>So you know your final step should be actually trying to add two numbers together or subtract numbers or whatever</p>



<p>You&#8217;re doing to make sure that you got the binary correct</p>



<p>So let&#8217;s see</p>



<p>Hmm</p>



<p>I guess maybe your first indication that the result was going to be positive would be that</p>



<p>there&#8217;s a zero there. And just, you know, as a sanity check, you look at the top and you&#8217;re like,</p>



<p>well, I was going to subtract a small number from a larger number. So the result should probably be</p>



<p>positive, right? Like 29 is like way lower than 109. So it should be positive, which means the</p>



<p>final result should have a zero at that leftmost position. Okay, so that&#8217;s two&#8217;s compliment,</p>



<p>two&#8217;s complement how to convert numbers from positive to negative in two&#8217;s complement you</p>



<p>know what the sign bit means and all that stuff and how to perform subtraction via two&#8217;s complement</p>



<p>i hope you enjoyed this video thank you for watching i hope you learned a little bit of</p>



<p>stuff and had a little bit of fun see you in the next video hey everybody thanks for watching this</p>



<p>video again from the bottom of my heart i really appreciate it i do hope you did learn something</p>



<p>If you could do me a please, a small little favor, could you please subscribe and follow this channel or these videos or whatever it is you do on the current social media 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 me a kindness and subscribe.</p>



<p>in the middle of the night and I just wake up because I know somebody</p>



<p>subscribed or followed. It just wakes me up and I get filled with joy. That&#8217;s</p>



<p>exactly what happens every single time. So you could do it as a nice favor to me</p>



<p>or you could you could troll me if you want to just wake me up in the middle</p>



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



<p>will happen. Also if you look at the middle of the screen right now you</p>



<p>should see a QR code which you can scan in order to go to the website which I</p>



<p>think is also named somewhere at the bottom of this video and it&#8217;ll take you</p>



<p>you to my main website where you can just kind of like see all the videos I published and the</p>



<p>services and tutorials and things that I offer and all that good stuff and if you have a suggestion</p>



<p>for clarifications or errata or just future videos that you want to see please leave a comment or if</p>



<p>you just want to say hey what&#8217;s up what&#8217;s going on you know just send me a comment whatever I also</p>



<p>wake up for those in the middle of the night I get I wake up in a cold sweat and I&#8217;m like</p>



<p>it would really mean the world to me. I would really appreciate it. So again,</p>



<p>thank you so much for watching this video and enjoy the cool music as I fade</p>



<p>into the darkness, which is coming for us all.</p>



<p>Thank you.</p>
<p>The post <a href="https://www.NeuralLantern.com/master-twos-complement-convert-subtract-negative-binary-numbers/">Master Two&#8217;s Complement: Convert &amp; Subtract Negative Binary Numbers</a> appeared first on <a href="https://www.NeuralLantern.com">NeuralLantern.com</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://www.NeuralLantern.com/master-twos-complement-convert-subtract-negative-binary-numbers/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
	</channel>
</rss>
