From the course: R for Data Science: Lunch Break Lessons

Unlock this course with a free trial

Join today to access over 22,600 courses taught by industry experts.

bitwise

bitwise

- [Instructor] Bitwise operators such as and or or or exclusive or are a throwback to the days of Assembler language and small computers. Given big data and data science, the call for bitwise operators may not be as much as it used to be but it's handy to know that R has these functions built in and they're there if you need 'em. So, let's take a couple of minutes and look at those. The first thing you'll want to know about is intToBits, I-N-T ToBits and if I give it a value, let's say eight, what I get back is a representation of eight in bits and you'll notice that its 00 00 00 00 01. In binary that's equal to eight. If you've worked in binary before, you may find that those numbers are somewhat reversed, but in this case this is the way that R represents that and it's in a 32-byte format. Compare intToBits eight with intToBits one and you'll see that the first value of intToBits one is one which is a binary one. Now, what can you do with all this? You can do a bitwise and and to do…

Contents