Do it by the position:
1 X (16X16X16) = 4096
5 X (16X16) = 1280
B X (16) = 176
3
Now add them all up: 4096+1280+176+3 = 5555
Chat with our AI personalities
16 is the 4th power of 2. So a hexadecimal number is converted to binary by replacing each hex digit by the 4-bit binary number having the same value. Conversely, in converting binary to hexadecimal, we group every 4 bits starting at the decimal (binary?) point and replace it with the equivalent hex digit. For example, the hexadecimal number 3F9 in binary is 1111111001, because 3 in binary is 11, F (decimal 15) is 1111, and 9 is 1001.
Use the %X modifier of printf.Code Example:#include int main(void) { unsigned int iMyNumber = 255; printf("The number %u interpreted as hexadecimal is %X.\n", iMyNumber, iMyNumber); return 0; }
The best way is to first convert hexadecimal to binary and then to octal. For example the hexadcimal number B4EA is in binary: B 4 E A 1011 0100 1110 1010 Thus B4EA (hexadecimal) = 1011010011101010 (binary) We add leading zeros to the binary number in order to be able to divide the number in sets of 3 digits. Then we convert easy to octal as follows: 001 011 010 011 101 010 1 3 2 3 5 2 Therefore 1011010011101010 (binary) = 132352 (octal) and from here you have your result: B4EA (hexadecimal) = 132352 (octal)
0x means hexadecimal (base-16). Just like in decimal, 1 and 01 are the same number.
The radix refers to the base of a number system: the total number of possible digits. The decimal number system that we all use is base ten, as it has ten distinct digits (0,1,2,3,4,5,6,7,8,9). Commonly used bases in computing include binary, octal, and hexadecimal, which have two, eight, and sixteen digits, respectively.