How to turn hexadecimal into decimal using brain?

2020-05-16 01:42发布

Opening the calculator to do such tiny stuff appears annoying to me ,and I strongly believe in ths saying "the more you know,the better!" so here I am asking you how to convert hexadecimal to decimal.

Till that moment I use the following formula:

Hex:        Decimal:
12          12+6
22          22+2*6
34          34+3*6
49          49+4*6
99          99+9*6

I get confused when I move on at higher numbers like C0 or FB

What is the formula(brain,not functional) that you're using?

标签: hex
9条回答
不美不萌又怎样
2楼-- · 2020-05-16 02:36

Here's another method that doesn't involve powers of 16 and can be done with pencil and paper:

Start with the leftmost digit. Multiply it by 16 and add to it the second-from-the-left digit. Then multiply the result by 16 and add to it the third-from-the-left digit. And so on.

For example, converting 0x20A5 to decimal:

  2 * 16 +  0 = 32
 32 * 16 + 10 = 522   (remember that A is 10 decimal)
522 * 16 +  5 = 8357

And the result of the conversion is 8,357.

查看更多
甜甜的少女心
3楼-- · 2020-05-16 02:37

I pretty much stopped doing this when I found the hex numbers I was working with were 32 bits. Not much fun there.

For smaller numbers, I (eventually) memorized some patterns: 10 = 16, 20 = 32, 40 = 64, 80 = 128 (because 100 = 256, and 80 is one bit less). 200 = 512 I remember because of some machine I used to use whose page size was 512 (no longer remember what machine!). 1000 = 4096 because that's another machine's page size.

also, 64=100, 32=50, B8=200

That's about all. Beyond that, I add.

查看更多
兄弟一词,经得起流年.
4楼-- · 2020-05-16 02:37

For the record, your brain does use a functional method of finding the answer. Here's the function my brain uses to find the value of a hexadecimal number:

  1. Divide the hexadecimal number into individual digits.
  2. Convert each digit to it's decimal value (so 0-9 stay the same, A is 10, B is 11, etc.)
  3. Starting at the rightmost digit, multiply each value by 16^X power, where X is the distance from the rightmost digit (so the rightmost digit is 16^0, or 1, next is 16^1, or 16, next is 16^2, or 256, etc.)
  4. Add all the values together.
查看更多
登录 后发表回答