Last active
October 18, 2019 20:00
-
-
Save danfinn/4efe3b405a01497521ac26745eff341b to your computer and use it in GitHub Desktop.
This file contains 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
This makes sense to me now but I figure down the road it might be somehting worth having so I can refer back to it. | |
Base2 (binary) works like so. A byte is made up of 8 bits. Inside each you can either store a 0 or a 1 (2 options, hence base 2). | |
Your 8 bits are represented like so: | |
| 128 (2 ** 7) | 64 (2 ** 6) | 32 (2 ** 5) | 16 (2 ** 4) | 8 (2 ** 3) | 4 (2 ** 2) | 2 (2 ** 1) | 1 (2 ** 0) | | |
To represent 42 your byte would be: 0 0 1 0 1 0 1 0 (1 x 32, 1 x 8, 1 x 2) | |
Taking it a step further base16 (hexadecimal) works in a similar way but it has 16 values in each bit (0 - 15, still represented by a single character). | |
It uses 0-9 and then a-f to represent 10-15 | |
| 268435456 | 16777216 | 1048576 | 65536 (16 ** 4) | 4096 (16 ** 3) | 256 (16 ** 2) | 16 (16 ** 1) | 1 (16 ** 0) | | |
To represent 911 your byte would look like : 0 0 0 0 0 3 8 f (3 x 256, 8 x 16, 15 x 1) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment