Chapter 2
Page 12
-
Binary to hexadecimal
0100 0101 0110 0111=45671000 1001 1010 1011=89ab1111 1110 1101 1100=fedc0000 0010 0101 0010=0252
-
Hexadecimal to binary
83af=1000 0011 1010 11119001=1001 0000 0000 0001aaaa=1010 1010 1010 10105555=0101 0101 0101 0101
- Number of bits
ffffffff, 32 bits7fff58b7def0, 48 bit1111in binary is 4 bits1111in hexadecimal is 16 bits
- Number of hexadecimal digits
- 8 bits, 2 hex digits
- 32 bits, 8 hex digits
- 64 bits, 16 hex digits
- 10 bits, 3 hex digits
- 20 bits, 5 hex digits
- 7 bits, 2 hex digits
Page 15
-
r = 10, n = 8, d7 = 2, d6 = 9, d5 = 4, d4 = 5, d3 = 8, d2 = 2, d1 = 5, d0 = 4 and r = 16, n = 8, d7 = 2, d6 = 9, d5 = 4, d4 = 5, d3 = 8, d2 = 2, d1 = 5, d0 = 4
- Binary to decimal
1010 1010= 1700101 0101= 851111 0000= 2400000 1111= 151000 0000= 1280110 0011= 990111 1011= 1231111 1111= 255
- Binary to decimal
1010 1011 1100 1101= 439810001 0011 0011 0100= 49161111 1110 1101 1100= 652440000 0111 1101 1111= 20151000 0000 0000 0000= 327680000 0100 0000 0000= 10240111 1011 1010 1010= 316580011 0000 0011 1001= 12345
- Hexadecimal to decimal
a000= 40960ffff= 655350400= 10241111= 43698888= 349520190= 400abcd= 439815555= 21845
Page 18
- Unsigned decimal to hexadecimal
- 100 =
64 - 123 =
7b - 10 =
0a - 88 =
58 - 255 =
ff - 16 =
10 - 32 =
20 - 128 =
80
- 100 =
- Unsignged decimal to hexadecimal
- 1024 =
0400 - 1000 =
03e8 - 32768 =
8000 - 32767 =
7fff - 256 =
0100 - 65535 =
ffff - 4660 =
1234 - 43981 =
abcd
- 1024 =
Page 22
- Uppercase A - F
- A:
0x41 - B:
0x42 - C:
0x43 - D:
0x44 - E:
0x45 - F:
0x46
- A:
-
Lowercase
char code char code char code char code char code a 0x61g 0x67m 0x6ds 0x73y 0x79b 0x62h 0x68n 0x6et 0x74z 0x7ac 0x63i 0x69o 0x6fu 0x75d 0x64j 0x6ap 0x70v 0x76e 0x65k 0x6bq 0x71w 0x77f 0x66l 0x6cr 0x72x 0x78 -
Uppercase
char code char code char code char code char code A 0x41G 0x47M 0x4dS 0x53Y 0x59B 0x42H 0x48N 0x4eT 0x54Z 0x5aC 0x43I 0x49O 0x4fU 0x55D 0x44J 0x4aP 0x50V 0x56E 0x45K 0x4bQ 0x51W 0x57F 0x46L 0x4cR 0x52X 0x58 -
Punctuation
char code char code char code char code char code spc 0x20’ 0x27. 0x2e? 0x3f` 0x60! 0x21( 0x28/ 0x2f@ 0x40{ 0x7b” 0x22) 0x29: 0x3a[ 0x5b} 0x7c# 0x23* 0x2a; 0x3b\ 0x5c| 0x7d$ 0x24+ 0x2b< 0x3c] 0x5d~ 0x7e% 0x25, 0x2c= 0x3d^ 0x5e& 0x26- 0x2d> 0x3e_ 0x5f
Page 30
-
/* dec2Hex.c * Converts from decimal to hexadecimal */ #include <stdio.h> int main(void) { unsigned int value; printf("Decimal: "); scanf("%u", &value); printf("%u = 0x%02x\n", value, value); return 0; } -
/* hex2Dec.c * Converts from hexadecimal to decimal */ #include <stdio.h> int main(void) { unsigned int value; printf("Hexadecimal: "); scanf("%x", &value); printf("0x%02x = %u\n", value, value); return 0; } - The integer is -1, and the string is
0xffffffff.