Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to convert decimal to hexadecimal using brain?

Tags:

math

decimal

hex

Since I knew how to manually convert hexadecimal to decimal using this method. Read from right to left, the last digit multiplied by the constant value 16 and plus the first digit.

For example:
12h = 2 + (1 * 16) = 18
99h = 9 + (9 * 16) = 153

How do I convert back into hex from decimal?

like image 576
Chozo Qhai Avatar asked Oct 08 '13 04:10

Chozo Qhai


People also ask

What is the easiest way to convert decimal to hexadecimal?

Take decimal number as dividend. Divide this number by 16 (16 is base of hexadecimal so divisor here). Store the remainder in an array (it will be: 0 to 15 because of divisor 16, replace 10, 11, 12, 13, 14, 15 by A, B, C, D, E, F respectively). Repeat the above two steps until the number is greater than zero.

How is hexadecimal code calculated?

Take the first number, 220, and divide by 16. 220 / 16 = 13.75, which means that the first digit of the 6-digit hex color code is 13, or D. Take the remainder of the first digit, 0.75, and multiply by 16. 0.75 (16) = 12, which means that the second digit of the 6-digit hex color code is 12, or C.

What is the easiest way to convert hexadecimal to binary?

Hexadecimal to binarySplit the hex number into individual values. Convert each hex value into its decimal equivalent. Next, convert each decimal digit into binary, making sure to write four digits for each value. Combine all four digits to make one binary number.


2 Answers

enter image description here

As you can see in the picture above. You need to draw a table in your brain

Lets take 456 as example.

If we divide 456 by 16 . Remainder = 8 & Quotient = 28

We further divide 28 by 16 and get remainder = 12 & quotient = 1

Now further dividing 1 by 16 results in remainder = 1 and quotient = 0

So we stop.

Now we take the remainders, bottom up.

1 , 12 , 8

Converting 12 in hex notation gives C.

So the answer is 1C8

like image 147
Sorter Avatar answered Sep 27 '22 22:09

Sorter


To convert from decimal to hex you must know the powers of 16. 16^1 is obviously 16; 16^2 is 256; 16^3 is 4096; 16^4 is 65536; etc.

For each power of 16, divide the number by that power to get one hex digit. Then take the remainder and divide by the next lower power of 16.

This is enough of a hassle that it's easiest to let a calculator do it, or use a scripting language such as Python.

like image 21
Mark Ransom Avatar answered Sep 27 '22 22:09

Mark Ransom