KaoruKohashigawa

Thanks for the cut

journey-to-greatness tips eric thomas

Pushing Binaries

cs

![binary road way](https://images.unsplash.com/photo-1449182325215-d517de72c42d?crop=entropy&fit=crop&fm=jpg&ixjsv=2.1.0&ixlib=rb-0.3.5&q=80&w=900) [Photo by Jon Ottosson](https://unsplash.com/jonottosson) I've been trying to get better at algorithms and computer science materials. Which lead me to the exploration of binary numbers. While looking into binaries, I saw a really interesting pattern. If you want to push the 1 to a higher number just add by an exponent of 2. I.e. if you're trying to flip the 5th zero in 100,000 ( i.e. turn it to 110,000 ) add 2 ^ 4 power ( 16 ) to your number. I.e. 32 ( 100,000 + 10,000 ) + 16 = 48 ( 110,000 ) ```ruby 16.to_s(2) # => "10000" 32.to_s(2) # => "100000" (32 + 2 ** 4).to_s(2) #= > "110000" ``` If you need to turn off a bit, you'd subtract 2 ^ 4. Where 4 is the position you want to turn off subtracted by one. I wonder if this has any applications? I suppose if I dig deeper I'll find my answers. It's pretty trippy how involved math is with the basis of computers. It makes me realize how super interconnected our universe really is. More so how much we might not know.

Post Message

javascript post message

Caught by the Cheese

motivation career eric thomas zig ziglar