Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- A2B hex to bin (dec after, optionally). First, remember that hex numbers are easier to handle in groups of pairs. So let's turn A2B into:
- 0A 2B
- We can then convert each one seaparately, to make life easier. First, let's do 2B. Since 2 hex digits make up 1 byte (just memorize this), we know there are 8 bits in binary for 2 hex digits. Or 4 bits per each hex digit. Then convert each ditit into decimal in your head (remember 0-9 in hex is 0-9 in decimal, then they go A=10, B=11, C=12, D=13, E=14, F=15, so in total you have 16 different digits... hence "hex"). Since 2 in hex is 2 in dec, it's easy.. we can just convert it to binary (you know how) = 0010. B is a bit harder, though:
- xxxx xxxx
- 0010 ???? B = 11 (cause 10 is A, so B is 11) 11 dec in bin is?
- 0010 1011
- 0A?
- xxxx xxxx
- 0000 ???? A = 10, so..
- 0000 1010
- So 0A2B hex in bin is:
- 00001010 00101011
- then you can convert this to decimal the usual way:
- remember, you can just build the table bigger for longer numbers
- 1 2 4 8 16 32 64 128 256 512 1024 2048 (think RAM bytes)
- 2048 + 0 + 512 + 0 + 0 + 0 + 32 + 0 + 8 + 0 + 2 + 1 = 2603
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement