Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

A shorthand for base 2 (binary)

Tags:

hex

binary

octal

I was doing TryHackMe and I encountered this question. I got this answer by looking through some help from the TryHackMe forum but I could not find an explanation to why 16 is the shorthand for base 2? Can someone explain to me why 16 is the correct answer in this case but not Base 8? Thank you for your help enter image description here

like image 236
Hai Vo Avatar asked Sep 12 '25 21:09

Hai Vo


1 Answers

Hexidecimal is used extensively as a shorthand for binary. Because it is base 16 with 16 being a power of 2, conversion from binary to hex is clean. All the possible values in a 4 digit binary number can be represented by a 1 digit hex number using all its possible values. A 4 digit binary number can represent values 0-15 (decimal), and a 1 digit hex number can represent values 0-15 (decimal).

To convert from binary to hex, so can use the same process, but the numbers being multiplied and added need to be hex numbers. For example, 10010b = 124 + 023 + 022 + 121 + 020 = 110 + 08 + 04 + 12 + 01 = 0x12. Note that each number is in hex, and the first term, 110, would be 116 in decimal.

In practice, I think most folks convert from binary to decimal and then from decimal to hex. Something like: 10010b has a 16 plus a 2 which is 18. That’s more than 16 and less than 32, so the second position has a 1 which is 16 leaving 2, so 0x12 is the answer.

Source:- https://practicalee.com/binary/

I had the same question n this is what I found! hope it helps.

like image 113
Tulika Avatar answered Sep 15 '25 04:09

Tulika