Created
October 22, 2014 21:13
-
-
Save aarti/5de3952b998010c9c28b to your computer and use it in GitHub Desktop.
ruby integers can be accessed as binary arrays
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
irb(main):019:0> a | |
=> 12 | |
irb(main):014:0> a.to_s(2) | |
=> "1100" | |
irb(main):015:0> a[0] | |
=> 0 | |
irb(main):016:0> a[1] | |
=> 0 | |
irb(main):017:0> a[2] | |
=> 1 | |
irb(main):018:0> a[3] | |
=> 1 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment