How did Gravity get so many awards? I didn’t think that it was a very good movie.
I mean, sure it was nicely made. It had good effects. But it was an hour and a half of Sandra Bullock breathing heavily and being incompetent. I just don’t see it. To some extent, a lot of people would freak out; on the other hand, you’re supposed to be a professional.
I came across this odd piece of code today:
data = (char)((1<<7) + (1<<5));
Can you figure out what it’s doing? It took me a while as well.
It’s doing a bitwise-OR of the data. But this ONLY works because of how the bits are shifted. In this particular case, it does a bitwise-OR because no bits overflow. For example, in base-10, if we have two numbers that we are adding together, and one of the numbers is 0, we can essentially just ignore it and put the two numbers together(in this example, the 1s place and 10s place only have one number each in them, so you can basically just combine them):
You can do the same thing with binary numbers:
Note that because there is no overflow in any place, this will have the same result if you do an add or a bitwise-OR together. Clearly, if there are two bits in the same position in both numbers and you add them together, that will give you a different answer than if you or them together.