From decimal number
To two complementary base.
(you can write 5 digits after the comma)
a) 127.375
b) -67
c) -18.32
The Correct Answer and Explanation is:
Step 1: Understand the task
- We want to represent decimal numbers (both positive and negative) as binary numbers in two’s complement form.
- For fractional parts, binary fractions are used (e.g., 0.1 in decimal ≈ 0.00011 in binary).
- We will keep up to 5 binary digits after the decimal point.
- For negative numbers, we convert the absolute value to binary, then find the two’s complement.
a) 127.375
Step 2a: Convert integer part (127) to binary
127 in decimal to binary:
127 = 26+25+24+23+22+21+202^6 + 2^5 + 2^4 + 2^3 + 2^2 + 2^1 + 2^0
= 1111111₂
Step 3a: Convert fractional part (0.375) to binary
Multiply fractional part by 2 repeatedly:
- 0.375 × 2 = 0.75 → integer part: 0
- 0.75 × 2 = 1.5 → integer part: 1
- 0.5 × 2 = 1.0 → integer part: 1
- Fractional part is now zero, stop.
Binary fraction: 0.011
Pad to 5 digits after decimal: 0.01100
Final binary (positive number):
127.375 = 1111111.01100
b) -67
Step 2b: Convert 67 to binary
67 decimal to binary:
67 = 64 + 2 + 1 = 26+21+202^6 + 2^1 + 2^0 = 1000011₂
Step 3b: Find two’s complement of 67
We choose 8 bits to represent integer for clarity:
67 = 01000011 (8 bits)
Two’s complement:
- Invert bits: 10111100
- Add 1: 10111100 + 1 = 10111101
So, -67 in 8-bit two’s complement = 10111101
c) -18.32 (approximate fractional part)
Step 2c: Convert 18 to binary
18 decimal to binary:
18 = 16 + 2 = 24+212^4 + 2^1 = 10010₂
Step 3c: Convert fractional part 0.32 to binary
Multiply fractional part by 2:
- 0.32 × 2 = 0.64 → 0
- 0.64 × 2 = 1.28 → 1
- 0.28 × 2 = 0.56 → 0
- 0.56 × 2 = 1.12 → 1
- 0.12 × 2 = 0.24 → 0
Fractional binary: 0.01010 (5 digits)
Step 4c: Combine integer and fractional parts
18.32 ≈ 10010.01010 (binary)
Step 5c: Convert to two’s complement (negative)
We consider a fixed bit length to cover integer + fraction. For simplicity, represent integer part in 8 bits:
18 decimal = 00010010
Fractional part: .01010
Combine: 00010010.01010
Step 6c: Find two’s complement of this binary number
To find two’s complement of a fractional number:
- Invert all bits (including fractional part): Integer part 00010010 → 11101101
Fractional part 01010 → 10101 - So inverted: 11101101.10101
- Add 1 to the least significant bit of fractional part:
Adding 1 to .10101:
.10101
- 0.00001
= .10110
Final two’s complement:
11101101.10110
Summary of answers:
| Decimal | Two’s complement binary (5 fractional bits) |
|---|---|
| a) 127.375 | 1111111.01100 (positive, normal binary) |
| b) -67 | 10111101 (8-bit two’s complement integer) |
| c) -18.32 | 11101101.10110 (two’s complement with fraction) |
Explanation
Two’s complement is the standard method to represent signed integers in binary form. Positive numbers are represented as straightforward binary, while negative numbers are represented by the two’s complement of their absolute value. This method allows easy addition and subtraction in binary without separate sign handling.
For integer parts, converting to binary is simple: divide the decimal number by 2 repeatedly and record remainders, or identify which powers of two sum to the number. For fractional parts, conversion uses repeated multiplication by 2, extracting the integer part of the result at each step until the fraction reaches zero or the desired precision is reached.
For positive decimal numbers with fractions (like 127.375), we convert the integer and fractional parts separately, then combine them using a binary point.
For negative numbers (like -67 and -18.32), we first convert the positive magnitude to binary. For integers, we decide the bit length (commonly 8, 16, or more bits) and convert to two’s complement by inverting the bits and adding 1. For fractional numbers, the two’s complement is computed by inverting all bits (including fractional bits) and adding one to the least significant fractional bit, considering the fractional precision.
Note that representing fractions in binary often leads to approximations, as many decimal fractions do not have exact binary equivalents. The 5-digit precision after the decimal point represents a balance between accuracy and simplicity.
In digital systems, two’s complement enables efficient arithmetic operations and easy detection of overflow. The representation allows seamless use of positive and negative values, critical in computing, signal processing, and control systems.
