Bitwise Operators

10 minutes
Share the link to this page
Copied
  Completed
You need to have access to the item to view this lesson.
One-time Fee
$99.99
List Price:  $139.99
You save:  $40
€93.07
List Price:  €130.30
You save:  €37.23
£79.62
List Price:  £111.47
You save:  £31.85
CA$136.60
List Price:  CA$191.24
You save:  CA$54.64
A$151.87
List Price:  A$212.63
You save:  A$60.75
S$135.20
List Price:  S$189.29
You save:  S$54.08
HK$781.33
List Price:  HK$1,093.90
You save:  HK$312.56
CHF 90.72
List Price:  CHF 127.01
You save:  CHF 36.29
NOK kr1,092.46
List Price:  NOK kr1,529.50
You save:  NOK kr437.03
DKK kr694.20
List Price:  DKK kr971.90
You save:  DKK kr277.70
NZ$167.15
List Price:  NZ$234.02
You save:  NZ$66.86
د.إ367.25
List Price:  د.إ514.16
You save:  د.إ146.91
৳10,946.16
List Price:  ৳15,325.07
You save:  ৳4,378.90
₹8,342.71
List Price:  ₹11,680.13
You save:  ₹3,337.42
RM473.95
List Price:  RM663.55
You save:  RM189.60
₦123,487.65
List Price:  ₦172,887.65
You save:  ₦49,400
₨27,847.21
List Price:  ₨38,987.21
You save:  ₨11,140
฿3,679.53
List Price:  ฿5,151.49
You save:  ฿1,471.96
₺3,232.18
List Price:  ₺4,525.18
You save:  ₺1,293
B$511.10
List Price:  B$715.57
You save:  B$204.46
R1,851.52
List Price:  R2,592.21
You save:  R740.68
Лв181.98
List Price:  Лв254.78
You save:  Лв72.80
₩135,881.87
List Price:  ₩190,240.05
You save:  ₩54,358.18
₪371.60
List Price:  ₪520.25
You save:  ₪148.65
₱5,713.97
List Price:  ₱7,999.79
You save:  ₱2,285.82
¥15,308.41
List Price:  ¥21,432.39
You save:  ¥6,123.98
MX$1,693.57
List Price:  MX$2,371.07
You save:  MX$677.49
QR364.01
List Price:  QR509.63
You save:  QR145.62
P1,365.33
List Price:  P1,911.52
You save:  P546.18
KSh13,468.65
List Price:  KSh18,856.65
You save:  KSh5,388
E£4,794.02
List Price:  E£6,711.82
You save:  E£1,917.80
ብር5,699.43
List Price:  ብር7,979.43
You save:  ብር2,280
Kz83,741.62
List Price:  Kz117,241.62
You save:  Kz33,500
CLP$94,755.52
List Price:  CLP$132,661.52
You save:  CLP$37,906
CN¥723.62
List Price:  CN¥1,013.10
You save:  CN¥289.48
RD$5,785.38
List Price:  RD$8,099.76
You save:  RD$2,314.38
DA13,457.99
List Price:  DA18,841.73
You save:  DA5,383.73
FJ$225.30
List Price:  FJ$315.43
You save:  FJ$90.13
Q775.21
List Price:  Q1,085.33
You save:  Q310.11
GY$20,876.73
List Price:  GY$29,228.26
You save:  GY$8,351.52
ISK kr13,989.60
List Price:  ISK kr19,586
You save:  ISK kr5,596.40
DH1,008.69
List Price:  DH1,412.20
You save:  DH403.51
L1,771.31
List Price:  L2,479.90
You save:  L708.59
ден5,730.13
List Price:  ден8,022.42
You save:  ден2,292.28
MOP$803.11
List Price:  MOP$1,124.38
You save:  MOP$321.27
N$1,860.85
List Price:  N$2,605.27
You save:  N$744.41
C$3,673.63
List Price:  C$5,143.23
You save:  C$1,469.60
रु13,311.40
List Price:  रु18,636.50
You save:  रु5,325.09
S/375.46
List Price:  S/525.66
You save:  S/150.20
K383.63
List Price:  K537.10
You save:  K153.47
SAR375.03
List Price:  SAR525.05
You save:  SAR150.02
ZK2,685.42
List Price:  ZK3,759.69
You save:  ZK1,074.27
L463.14
List Price:  L648.42
You save:  L185.27
Kč2,328.17
List Price:  Kč3,259.54
You save:  Kč931.36
Ft36,248.95
List Price:  Ft50,749.98
You save:  Ft14,501.03
SEK kr1,083.98
List Price:  SEK kr1,517.62
You save:  SEK kr433.63
ARS$87,816.53
List Price:  ARS$122,946.66
You save:  ARS$35,130.12
Bs689.12
List Price:  Bs964.79
You save:  Bs275.67
COP$389,940.87
List Price:  COP$545,932.82
You save:  COP$155,991.94
₡50,893.45
List Price:  ₡71,252.86
You save:  ₡20,359.41
L2,475.75
List Price:  L3,466.15
You save:  L990.40
₲747,391.81
List Price:  ₲1,046,378.43
You save:  ₲298,986.62
$U3,833.15
List Price:  $U5,366.56
You save:  $U1,533.41
zł402.67
List Price:  zł563.75
You save:  zł161.08
Already have an account? Log In

Transcript

Hello, in this video we are going to cover bitwise operators. So bitwise operators essentially just perform a operation on the individual binary bits of the information that we have. And so imagine if we have a couple of variables for the VA one, assigning the value of eight and it says the bar two and assign it the value of four. Now I'll find this one the value of five and this one default. So, in binary comment here, in binary, this would be 00. So 1200 food is due within four bits.

So you Just the new missing 01. So b one plus the two plus four plus the one, that's okay, we need the eight. We don't need any. So it's one plus one plus one in binary form. So it is April 14 12 plus two one, which is 13. And now, little comment, and for this, it's 0101.

So one plus four, which is five. So that's both of these numbers in both right before doing. Let me just put out the different binary operators. I do print and I put var one. You could obviously just put in an explicit number and it can be any like information really, really or have some sort of binary value. We don't have numbers and var one.

I'm going to put The operator and single and double and if you know something different we'll be covering in a separate video. So this is the binary n var two. So what this checks is, if like in the column so if I were to put this in the same row wait this is let me put another comment here, just to make it a little nicer and we'll produce a slightly different format. I am going to put Boys and girls and now this is what is produced by the end operator. So the end operator he goes through all of the columns does he checks if both of the bits are on so if it's on the will do this on be easy for me to type so, one and zero on only one of them's onto that produces zero is one on one on yes is you know zero they're both lossless zero is 1111 so you It literally produces this result.

So it should just print out five. So if we run it and see what Yeah. Wait three more seconds. Okay, so that's what the end operator does. So there is a number operator. So I'm actually going to boot this up.

And the other operator is called the OR operator and you use the underscore for this with the underscore D, the vertical line the pipe. And what this does, it checks if just one of the bits is on in the column. So this will be true, this will be true, this wouldn't be true because none of them are, this will also be true. So now you know you'll be 13 you won't always you know result in the other number depending on author number you've got and before printing Today, I'll show you the other apprentice. So there's something called an XOR operator. So this is called or this is excellent.

This is an exclusive OR operator. So this would result in zero here because why does it say it goes through the night without one day. He goes through every column and say, each one of them on only one, if the both one then you'll return false. So one of zero ones on. So it's one one on one demo Funsters 00 and zero both off the 01 on one the both on to the zero, and the operator, this is the little carrot, the arrow pointing up. And now what we're going to do is check the winner look at the ones complement operator, which is you know, just by affectively flipping the bits so if all For this, you only need one of one variable pay for do the little squiggly line, the blade, it's called the tilde tilde the a blade is called the tilde I actually really want to know now.

So yeah, till the end at the end. Okay. So what this does is if I get rid of this, the ones complement nicely and he just flips them the bit so this returns really long it will turn to zero before turn to a zero. So this will just produce the value of two so too, we'll again, we'll have a look at that very soon. And a couple more. And these are binary shifts.

So if I just go left, it's sort of hard to see where the operators will come in handy. My thinking the arithmetic operated yabbies time, comparison operators vibe and assignment, but where will I use bitwise? And I think not, you're using all stuff. But when you start getting some hardcore coding, we especially with gains, and for 3d rendering, you will start using bitwise operators or, you know, on really low level stuff, just immense and use one, knowing how to use them is also useful. So this just, you know, essentially shift, it just moves the number of bits. It's literally that simple.

So If I put in one shifted by one place, and then I'm going to do a binary right? And to shift it right, just that so if we run this, see what we get. For actually next to this, I'm going to write all of the values that he should be getting. So this should just follow this 14, this should get a This was produced to 13 stake somewhere at negative 14 So once complimented up to one there are made mistakes and the ones complement and they don't make the mistake on the one compliment now that's the main mistake in this Yeah it does. Look You know what I said? So yeah 13 would become mind for him you know, obviously take a look at the ones compliment a bit more and the binary shift will result in 26 a one var one initially it is 1101.

So he just moved the one place to the left and this one becomes volatile moves in one place to the Right, so you just have a 412 and the zeros here and that one just gets dropped off. So yeah, that's it for bitwise operators a lot to take in. I do agree with that a Ba Ba, that's what you're thinking. But just go the video again, how long the source code, and I'm sure you'll be fine. If you have any questions, feel free to reach out. And as usual, thanks for watching, and I'll see you in the next video.

Sign Up

Share

Share with friends, get 20% off
Invite your friends to LearnDesk learning marketplace. For each purchase they make, you get 20% off (upto $10) on your next purchase.