Subjects computer science

Binary Conversions

Step-by-step solutions with LaTeX - clean, fast, and student-friendly.

Search Solutions

Binary Conversions


1. **Problem:** Convert 13₁₀ to 8-bit binary. 2. **Formula/Method:** Use powers of two from $2^7$ to $2^0$ and find which powers sum to 13. 3. **Work:** - Powers: 128, 64, 32, 16, 8, 4, 2, 1 - 13 - 8 = 5 (bit for $2^3$ is 1) - 5 - 4 = 1 (bit for $2^2$ is 1) - 1 < 2 (bit for $2^1$ is 0) - 1 - 1 = 0 (bit for $2^0$ is 1) 4. **Binary bits:** 00001101 5. **Answer:** $13_{10} = 00001101_2$ --- 1. **Problem:** Represent $-75_{10}$ in 16-bit two's complement. 2. **Method:** Convert +75 to binary, invert bits, add 1. 3. **Work:** - +75 in binary (8-bit): 01001011 - Pad to 16-bit: 0000000001001011 - Invert bits: 1111111110110100 - Add 1: 1111111110110101 4. **Answer:** $-75_{10} = 1111111110110101_2$ --- 1. **Problem:** Convert $1110110101011001_2$ to hexadecimal. 2. **Method:** Group bits in 4s from right: 1110 1101 0101 1001 3. **Work:** - 1110 = E - 1101 = D - 0101 = 5 - 1001 = 9 4. **Answer:** $1110110101011001_2 = ED59_{16}$ --- 1. **Problem:** Convert "Welcome to COSC204!" to 8-bit ASCII binary. 2. **Method:** Use ASCII decimal codes, convert each to 8-bit binary. 3. **Work:** - W=87=01010111 - e=101=01100101 - l=108=01101100 - c=99=01100011 - o=111=01101111 - m=109=01101101 - e=101=01100101 - space=32=00100000 - t=116=01110100 - o=111=01101111 - space=00100000 - C=67=01000011 - O=79=01001111 - S=83=01010011 - C=67=01000011 - 2=50=00110010 - 0=48=00110000 - 4=52=00110100 - !=33=00100001 4. **Answer:** Concatenated binary string as above. --- 1. **Problem:** Signed 16-bit binary representation. 2. **a) 3046₁₀:** - Divide by 16: 3046 ÷ 16 = 190 r6 (6) - 190 ÷ 16 = 11 r14 (E) - 11 ÷ 16 = 0 r11 (B) - Hex: 0x0BE6 - Binary: 0000101111100110 3. **b) -2078₁₀:** - +2078 hex: 0x081E - Binary: 0000100000011110 - Invert: 1111011111100001 - Add 1: 1111011111100010 4. **c) -CC₁₆:** - CC hex = 0x00CC = 0000000011001100 - Invert: 1111111100110011 - Add 1: 1111111100110100 5. **d) 204₁₆:** - 0x0204 = 0000001000000100 --- 1. **Problem:** Compute $x - y$ by $x + (-y)$ in 16-bit binary. 2. **a) 3046 - 2078:** - 3046 = 0x0BE6 = 0000101111100110 - -2078 = 0xF7E2 = 1111011111100010 - Add: 0x0BE6 + 0xF7E2 = 0x03C8 - Decimal check: 3046 - 2078 = 968 - Binary: 0000001111001000 3. **b) 204₁₆ - CC₁₆:** - 204₁₆ = 0x0204 = 516 decimal - CC₁₆ = 0x00CC = 204 decimal - Two's complement of CC: 0xFF34 - Add: 0x0204 + 0xFF34 = 0x0138 - Decimal: 312 - Binary: 0000000100111000 --- 1. **Problem:** Truth tables for boolean functions. 2. **a) MUX(A,B,C) = (¬A ∧ B) ∨ (A ∧ C):** | A | B | C | ¬A | ¬A∧B | A∧C | MUX | |---|---|---|----|-------|-----|-----| | F | F | F | T | F | F | F | | F | F | T | T | F | F | F | | F | T | F | T | T | F | T | | F | T | T | T | T | F | T | | T | F | F | F | F | F | F | | T | F | T | F | F | T | T | | T | T | F | F | F | F | F | | T | T | T | F | F | T | T | 3. **b) XOR(A,B) = (A ∨ B) ∧ ¬(A ∧ B):** | A | B | A∨B | A∧B | ¬(A∧B) | XOR | |---|---|-----|-----|--------|-----| | F | F | F | F | T | F | | F | T | T | F | T | T | | T | F | T | F | T | T | | T | T | T | T | F | F | 4. **c) EQV(A,B) = (A ∧ B) ∨ (¬A ∧ ¬B):** | A | B | A∧B | ¬A | ¬B | ¬A∧¬B | EQV | |---|---|-----|----|----|-------|-----| | F | F | F | T | T | T | T | | F | T | F | T | F | F | F | | T | F | F | F | T | F | F | | T | T | T | F | F | F | T | --- 1. **Problem:** Evaluate specific cases from tables. 2. **Answers:** - MUX(T,F,T) = T - XOR(F,F) = F - EQV(T,F) = F --- 1. **Problem:** Little-endian byte order for 32-bit value $90AB12CD_{16}$ at address $4000_{16}$. 2. **Method:** Store least significant byte at lowest address. 3. **Work:** - Bytes: 90 AB 12 CD - Little-endian order: CD (4000), 12 (4001), AB (4002), 90 (4003) 4. **Answer:** Byte at address 4002 = AB --- 1. **Problem:** Memory dump at 5000₁₆; little-endian 32-bit integers. 2. **Given bytes:** - 5000: 78 - 5001: 56 - 5002: 34 - 5003: 12 - 5004: FE - 5005: DC - 5006: BA - 5007: 98 3. **Work:** - First integer: 0x12345678 = 305419896 decimal - Second integer: 0x98BADCFE = 2562383102 decimal (unsigned) 4. **Answer:** - First integer = 0x12345678 (305419896 decimal) - Second integer = 0x98BADCFE (2562383102 decimal unsigned)