课程: R for Data Science: Lunch Break Lessons

免费学习该课程!

今天就开通帐号,24,100 门业界名师课程任您挑!

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…

内容