Number Systems and Codes: Binary, Octal, Hex, Complements, BCD, Gray and ASCII · সংখ্যা পদ্ধতি ও কোড: বাইনারি, অক্টাল, হেক্সাডেসিমেল, কমপ্লিমেন্ট, বিসিডি, গ্রে ও অ্যাসকি
A number system is a positional way of writing numbers in a base: binary (base 2, digits 0–1), octal (base 8), decimal (base 10) and hexadecimal (base 16, digits 0–9 and A–F); to convert to decimal you multiply each digit by its place value (a power of the base) and add, from decimal you divide repeatedly by the base (multiply repeatedly for fractions), and between binary, octal and hex you group bits in threes or fours. Computers store negative integers in 2's complement (invert the bits and add 1), which gives an n-bit range of −2ⁿ⁻¹ to 2ⁿ⁻¹ − 1 (−128 to 127 for 8 bits). Codes give bit patterns a meaning: BCD writes each decimal digit in 4 bits, Gray code changes one bit between neighbours, excess-3 adds 3 to each digit, ASCII is a 7-bit character code (A = 65), Unicode covers every script (UTF-8 uses 1 to 4 bytes), and a parity bit detects single-bit errors.
সংখ্যা পদ্ধতি হলো একটি ভিত্তি (বেস) ধরে স্থানীয় মান অনুযায়ী সংখ্যা লেখার নিয়ম: বাইনারি (ভিত্তি ২, অঙ্ক ০–১), অক্টাল (ভিত্তি ৮), ডেসিমেল (ভিত্তি ১০) ও হেক্সাডেসিমেল (ভিত্তি ১৬, অঙ্ক ০–৯ ও A–F); দশমিকে নিতে প্রতিটি অঙ্ককে তার স্থানীয় মান দিয়ে গুণ করে যোগ করতে হয়, দশমিক থেকে নিতে ভিত্তি দিয়ে বারবার ভাগ করতে হয় (ভগ্নাংশের বেলায় বারবার গুণ), আর বাইনারি, অক্টাল ও হেক্সের মধ্যে তিনটি বা চারটি বিট করে দলে ভাগ করলেই চলে। কম্পিউটার ঋণাত্মক পূর্ণসংখ্যা রাখে ২-এর পরিপূরক (2's complement) পদ্ধতিতে (বিটগুলো উল্টে ১ যোগ), যাতে n বিটে পরিসর −২ⁿ⁻¹ থেকে ২ⁿ⁻¹ − ১ (৮ বিটে −১২৮ থেকে ১২৭)। কোড বিটের বিন্যাসকে অর্থ দেয়: বিসিডি প্রতিটি দশমিক অঙ্ক ৪ বিটে লেখে, গ্রে কোডে পাশাপাশি দুটি সংখ্যায় মাত্র একটি বিট বদলায়, এক্সেস-৩ প্রতিটি অঙ্কে ৩ যোগ করে, অ্যাসকি ৭ বিটের অক্ষর কোড (A = ৬৫), ইউনিকোড সব লিপি ধারণ করে (ইউটিএফ-৮ এক থেকে চার বাইট ব্যবহার করে), আর প্যারিটি বিট একটি বিটের ভুল ধরতে পারে।
- Asked in past exams
- 48
- Papers
- 40
1. Positional number systems and the base
In a positional system each digit's value depends on its place. The base (radix) b is the number of different digits, and the places are worth powers of b: ... b², b¹, b⁰ . b⁻¹, b⁻² ... Computers work in binary because their circuits have two stable states (on/off, high/low voltage); octal and hex are short ways for people to write binary. Modern computers work internally in binary; a few early machines, such as ENIAC and the IBM 1620 (Bangladesh's first computer), did their arithmetic in decimal.
| System | Base | Digits | 25 (decimal) written in it | Grouping |
|---|---|---|---|---|
| Binary | 2 | 0, 1 | 11001 | – |
| Octal | 8 | 0 – 7 | 31 | 3 bits per digit |
| Decimal | 10 | 0 – 9 | 25 | – |
| Hexadecimal | 16 | 0 – 9, A(10), B(11), C(12), D(13), E(14), F(15) | 19 | 4 bits per digit |
The first sixteen values, worth memorising:
| Dec | Bin | Oct | Hex | Dec | Bin | Oct | Hex | |
|---|---|---|---|---|---|---|---|---|
| 0 | 0000 | 0 | 0 | 8 | 1000 | 10 | 8 | |
| 1 | 0001 | 1 | 1 | 9 | 1001 | 11 | 9 | |
| 2 | 0010 | 2 | 2 | 10 | 1010 | 12 | A | |
| 3 | 0011 | 3 | 3 | 11 | 1011 | 13 | B | |
| 4 | 0100 | 4 | 4 | 12 | 1100 | 14 | C | |
| 5 | 0101 | 5 | 5 | 13 | 1101 | 15 | D | |
| 6 | 0110 | 6 | 6 | 14 | 1110 | 16 | E | |
| 7 | 0111 | 7 | 7 | 15 | 1111 | 17 | F |
So (E)₁₆ = 14 in decimal = (16)₈ = (1110)₂. Counting works the same in every base: after the largest digit you carry. The number after (77)₈ is (100)₈; continuing the hex sequence 6FC, 6FE in steps of 2 gives 700, 702, 704, 706. Base 3 (ternary) uses the digits 0, 1 and 2. A string such as 110101 could belong to any base of 2 or more, because it uses only the digits 0 and 1.
2. Any base to decimal (multiply by place values)
Multiply each digit by its place value and add.
Worked example 1: (1101.11)₂ to decimal.
| Digit | 1 | 1 | 0 | 1 | . | 1 | 1 |
|---|---|---|---|---|---|---|---|
| Place value | 2³ = 8 | 2² = 4 | 2¹ = 2 | 2⁰ = 1 | 2⁻¹ = 0.5 | 2⁻² = 0.25 | |
| Product | 8 | 4 | 0 | 1 | 0.5 | 0.25 |
Sum = 8 + 4 + 1 + 0.5 + 0.25 = 13.75.
More examples:
- (734)₈ = 7 × 64 + 3 × 8 + 4 = 448 + 24 + 4 = 476.
- (1F.01B)₁₆ = 1 × 16 + 15 + 0 ÷ 16 + 1 ÷ 256 + 11 ÷ 4,096 = 31 + 0.00390625 + 0.002685546875 = 31.006591796875 (≈ 31.0065918, the keyed option).
- (9D.AB6)₁₆ = 157 + 10 ÷ 16 + 11 ÷ 256 + 6 ÷ 4,096 = 157.66943359375.
3. Decimal to any base (divide for the integer part, multiply for the fraction)
Integer part: divide by the base repeatedly and read the remainders from the last to the first (bottom to top).
Worked example 2: 300 to hexadecimal.
| Division | Quotient | Remainder |
|---|---|---|
| 300 ÷ 16 | 18 | 12 → C |
| 18 ÷ 16 | 1 | 2 |
| 1 ÷ 16 | 0 | 1 |
Reading upward: (300)₁₀ = (12C)₁₆. Check: 1 × 256 + 2 × 16 + 12 = 300.
Fraction part: multiply the fraction by the base repeatedly; the integer parts that appear are the digits, read from the first to the last (top to bottom).
Worked example 3: 13.375 to binary.
- Integer 13: 13 ÷ 2 = 6 r 1, 6 ÷ 2 = 3 r 0, 3 ÷ 2 = 1 r 1, 1 ÷ 2 = 0 r 1 → read upward: 1101.
- Fraction 0.375: 0.375 × 2 = 0.75; 0.75 × 2 = 1.5; 0.5 × 2 = 1.0 (stop at 0) → read downward: .011.
- Answer: (13.375)₁₀ = (1101.011)₂.
Some fractions never end in binary: 0.3 × 2 = 0.6 → 0, 1.2 → 1, 0.4 → 0, 0.8 → 0, 1.6 → 1, 1.2 → 1, and the pattern repeats, so (0.3)₁₀ = (0.0100110011…)₂. Stop at the number of places the question asks for. The same method gives 0.6875 = (0.54)₈ = (0.B)₁₆.
Other results checked for this page: 2019 = (11111100011)₂; 1741 = (6CD)₁₆; 423 = (647)₈; 3000 = (BB8)₁₆; 2345 = (929)₁₆; 7491 = (1D43)₁₆; 2016 = (7E0)₁₆; 68 = (01000100)₂ in 8 bits; 1234567 = (100101101011010000111)₂.
4. Binary, octal and hex shortcuts (grouping)
Since 8 = 2³ and 16 = 2⁴, each octal digit is exactly 3 bits and each hex digit exactly 4 bits. Group from the binary point outward (to the left for the integer part, to the right for the fraction) and pad with zeros.
- (1011010)₂ → 101 1010 → (5A)₁₆; (1111011011)₂ → 11 1101 1011 → (3DB)₁₆.
- Octal to hex goes through binary: (734)₈ → 111 011 100 → regroup in fours: 1 1101 1100 → (1DC)₁₆. Likewise (4673)₈ = (9BB)₁₆.
- Hex to octal: (7B5)₁₆ → 0111 1011 0101 → regroup in threes: 011 110 110 101 → (3665)₈. Likewise (ABCD)₁₆ = (125715)₈.
- With a fraction: (16A.6)₁₆ = (101101010.011)₂ and (72.3)₈ = (111010.011)₂; their sum is 362.375 + 58.375 = 420.75 = (1A4.C)₁₆.
5. Binary arithmetic
| Addition | Result | Subtraction | Result | |
|---|---|---|---|---|
| 0 + 0 | 0 | 0 − 0 | 0 | |
| 0 + 1 | 1 | 1 − 0 | 1 | |
| 1 + 1 | 0, carry 1 (= 10) | 1 − 1 | 0 | |
| 1 + 1 + 1 | 1, carry 1 (= 11) | 0 − 1 | 1, borrow 1 |
Worked example 4: 10101 + 1011.
carries 1 1 1 1 1
1 0 1 0 1 (21)
+ 1 0 1 1 (11)
-------------
1 0 0 0 0 0 (32)
From the right: 1 + 1 = 0 carry 1; 0 + 1 + 1 = 0 carry 1; 1 + 0 + 1 = 0 carry 1; 0 + 1 + 1 = 0 carry 1; 1 + 0 + 1 = 0 carry 1; the last carry gives the leading 1. Answer 100000 (21 + 11 = 32).
Also: 11011 − 1101 = 1110 (27 − 13 = 14); 1101 × 101 = 1000001 (13 × 5 = 65, shift and add); 11001 ÷ 101 = 101 (25 ÷ 5 = 5). In hex, add in decimal and carry 16: 3A7 + 1F9 = 5A0 (7 + 9 = 16 → 0 carry 1; A + F + 1 = 26 → A carry 1; 3 + 1 + 1 = 5).
6. Signed numbers: sign-magnitude, 1's and 2's complement
| Method | How −x is formed | −5 in 8 bits | Zeros | Range for n bits | 8-bit range |
|---|---|---|---|---|---|
| Unsigned | (no negatives) | – | one | 0 to 2ⁿ − 1 | 0 to 255 |
| Sign-magnitude | Top bit 1 = negative, rest = magnitude | 10000101 | two (+0, −0) | −(2ⁿ⁻¹ − 1) to +(2ⁿ⁻¹ − 1) | −127 to +127 |
| 1's complement | Invert every bit of +x | 11111010 | two | −(2ⁿ⁻¹ − 1) to +(2ⁿ⁻¹ − 1) | −127 to +127 |
| 2's complement | Invert every bit, then add 1 | 11111011 | one | −2ⁿ⁻¹ to 2ⁿ⁻¹ − 1 | −128 to +127 |
Note that +5 is 00000101 in all of them. For 4 bits the 2's-complement range is −8 to +7; for 16 bits, −32,768 to +32,767. A short cut for the 2's complement: copy bits from the right up to and including the first 1, then invert the rest.
Worked example 5: 2's complement questions.
- 2's complement of 11100101: invert → 00011010, add 1 → 00011011.
- 2's complement of (65)₁₆: 65h = 01100101 → invert 10011010 → add 1 → 10011011.
- Value of 11111111 as an 8-bit 2's-complement number: the top bit is 1, so it is negative; its 2's complement is 00000001, so the value is −1 (not 255). Likewise 10000000 = −128.
- 9 − 5 by addition: 9 = 00001001, −5 = 11111011; 00001001 + 11111011 = 1 00000100. Drop the carry out of bit 8: 00000100 = 4.
Overflow: adding two numbers of the same sign can leave the range. 100 + 50 = 150 > 127, and the 8-bit pattern 10010110 reads as −106. Overflow has happened when two positives give a negative or two negatives give a positive.
Subtraction with the 1's complement (end-around carry): add the 1's complement of the number being subtracted; if a carry comes out of the top bit, add it back to the lowest bit instead of dropping it.
- 9 − 5: 00001001 + 11111010 = 1 00000011 → add the carry back: 00000011 + 1 = 00000100 = 4.
- 5 − 9: 00000101 + 11110110 = 11111011 with no carry out, so the result is negative; its 1's complement, 00000100, shows it is −4.
Complements in any base r: the (r−1)'s complement (diminished radix complement) of an n-digit number N is (rⁿ − 1) − N, found by subtracting each digit from r − 1; the r's complement (radix complement) is rⁿ − N, that is, the (r−1)'s complement + 1. In binary these are the 1's and 2's complements; in decimal they are the 9's and 10's complements. Example: the 9's complement of 4567 is 9999 − 4567 = 5432, and its 10's complement is 5432 + 1 = 5433. Decimal subtraction works the same way: 7250 − 3456 = 7250 + 6544 (the 10's complement of 3456) = 1 3794 → drop the carry → 3794.
Real numbers (floating point): IEEE 754 single precision stores a 32-bit number as 1 sign bit, 8 exponent bits (bias 127) and 23 fraction bits, with value (−1)ˢ × 1.fraction × 2ᴱ⁻¹²⁷, where E is the stored exponent. For example 1.0 = 0 01111111 000…0 = 3F800000h. Double precision uses 1, 11 (bias 1023) and 52 bits.
7. BCD, excess-3 and other codes
A code gives an agreed meaning to bit patterns. Weighted codes give each bit a fixed weight (binary, BCD 8421); non-weighted codes do not (excess-3, Gray). ASCII and EBCDIC are alphanumeric (character) codes, outside this split. Other weighted codes are 2421 (self-complementing) and 5211.
BCD (Binary Coded Decimal, 8421): each decimal digit is written separately in 4 bits; the patterns 1010 to 1111 are not used.
| Number | BCD | Pure binary |
|---|---|---|
| 59 | 0101 1001 | 111011 |
| 259 | 0010 0101 1001 | 100000011 |
BCD needs more bits than binary but converts to and from decimal digits easily (calculators, digital displays, money amounts).
BCD addition: add each 4-bit digit in binary; if a digit's sum is more than 9 (or gives a carry), add 0110 (6) to correct it.
- 0001 0011 (13) + 0010 0110 (26) = 0011 1001 (39): no digit exceeds 9, so no correction.
- 0101 1000 (58) + 0010 0111 (27): low digit 1000 + 0111 = 1111 (15 > 9) → + 0110 = 1 0101 → digit 5, carry 1; high digit 0101 + 0010 + 1 = 1000. Result 1000 0101 = 85.
Excess-3 (XS-3): each digit's BCD value plus 3 (0011). 0 → 0011, 5 → 1000, 9 → 1100, so 59 → 1000 1100. It is self-complementing: inverting the bits of a digit gives its 9's complement (2 = 0101 ↔ 7 = 1010), which made decimal subtraction easier in old hardware.
Watch the "6-bit BCD" question: the 4-bit BCD above codes digits only. The older 6-bit character code BCDIC (Binary Coded Decimal Interchange Code, 64 characters) is also called "BCD code"; an MCQ asking for "the number of bits in the BCD code used in computing" with options 6, 7, 12 and 18 expects six.
8. Gray code
In Gray code (reflected binary code) consecutive numbers differ in exactly one bit, which avoids false readings in rotary encoders and gives Karnaugh maps their order.
- Binary → Gray: copy the top bit; then each Gray bit = XOR of the binary bit and the binary bit to its left.
- Gray → binary: copy the top bit; then each binary bit = XOR of the binary bit just found and the next Gray bit.
Worked example 6. Binary 1011 → Gray: 1, 1⊕0 = 1, 0⊕1 = 1, 1⊕1 = 0 → 1110. Gray 1101 → binary: 1, 1⊕1 = 0, 0⊕0 = 0, 0⊕1 = 1 → 1001.
| Decimal | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Gray | 0000 | 0001 | 0011 | 0010 | 0110 | 0111 | 0101 | 0100 | 1100 | 1101 | 1111 | 1110 | 1010 | 1011 | 1001 | 1000 |
9. ASCII, Unicode and UTF-8
ASCII (American Standard Code for Information Interchange, 1963) is a 7-bit code with 128 characters (0–127): 0–31 and 127 are control codes, 32 is space, '0'–'9' are 48–57, 'A'–'Z' are 65–90 and 'a'–'z' are 97–122. Lowercase = uppercase + 32, so 'A' = 65 = 41h = 1000001 and 'a' = 97 = 61h. "Extended ASCII" is any 8-bit (256-character) extension. IBM mainframes use a different 8-bit code, EBCDIC.
Unicode gives every character of every script a code point, written U+hex, from U+0000 to U+10FFFF (1,114,112 code points). Bangla letters are in the block U+0980–U+09FF. A code point is stored using an encoding:
| Code points | UTF-8 bytes | Byte pattern | Example |
|---|---|---|---|
| U+0000 – U+007F | 1 | 0xxxxxxx | 'A' U+0041 → 41 (the same as ASCII) |
| U+0080 – U+07FF | 2 | 110xxxxx 10xxxxxx | 'é' U+00E9 → C3 A9 |
| U+0800 – U+FFFF | 3 | 1110xxxx 10xxxxxx 10xxxxxx | 'অ' U+0985 → E0 A6 85 |
| U+10000 – U+10FFFF | 4 | 11110xxx 10xxxxxx 10xxxxxx 10xxxxxx | an emoji, U+1F600 → F0 9F 98 80 |
UTF-8 is backward compatible with ASCII and is the main encoding of the web. UTF-16 uses 2 or 4 bytes per character and UTF-32 always 4.
10. Parity and error detection
A parity bit is added so that the total number of 1s is even (even parity) or odd (odd parity). The receiver counts the 1s; a wrong count shows an error.
| Data (7 bits) | Number of 1s | Even-parity bit | Odd-parity bit |
|---|---|---|---|
| 1000001 ('A') | 2 | 0 | 1 |
| 1101011 | 5 | 1 | 0 |
Parity detects any single-bit (indeed any odd number of) errors but misses two-bit errors and cannot say which bit is wrong; Hamming codes add more check bits to correct a single-bit error. The number of bits in which two values differ (the Hamming distance) is the count of 1s in their XOR: 31 = 00011111 and 14 = 00001110, XOR = 00010001, so 2 bits must change.
11. Tricky exam cases
- Bits needed: to represent N different values you need ⌈log₂ N⌉ bits: 1,000 values → 10 bits (2¹⁰ = 1,024); 26 letters → 5 bits.
- Masking: AND with 0Fh keeps the lower 4 bits (and clears the upper 4); OR with 0Fh sets them to 1; XOR with 0Fh inverts them.
- Counter range: a binary counter clocked at 256 kHz whose last flip-flop gives 2 kHz divides by 256 ÷ 2 = 128 = 2⁷, so it has 7 flip-flops and counts 0 to 127. A 4-bit BCD (decade) counter has 10 states.
- ADC output: an 8-bit ADC with a 2.56 V full scale has 2⁸ = 256 steps of 2.56 ÷ 256 = 0.01 V, so 1.7 V gives 1.7 ÷ 0.01 = 170 = 10101010. (If a key divides the full scale by 255 steps instead, it gets 169 = 10101001; state the convention you use.)
- Mixed-base sums: convert everything to one base first. (9D.AB6)₁₆ + (306.51)₁₀ = 157.66943359375 + 306.51 = 464.17943359375 in decimal, then convert. (11011)₂ + (1010101110.10111)₂ = (1011001001.10111)₂ = (2C9.B8)₁₆.
- Two's-complement reading: an 8-bit register holding 11111111 is −1 if signed and 255 if unsigned; the question decides which.
Practice · অনুশীলন
- Convert (2019)₁₀ to binary, octal and hexadecimal.
Answer
Binary 11111100011; grouping in threes gives octal 3743 (011 111 100 011); grouping in fours gives hex 7E3 (0111 1110 0011).
- Convert (0.8125)₁₀ to binary and to octal.
Answer
0.8125 × 2 = 1.625 → 1; 0.625 × 2 = 1.25 → 1; 0.25 × 2 = 0.5 → 0; 0.5 × 2 = 1.0 → 1, so (0.1101)₂. Grouping 110 100 gives (0.64)₈.
- Write −19 in 8-bit sign-magnitude, 1's complement and 2's complement.
Answer
+19 = 00010011. Sign-magnitude 10010011; 1's complement 11101100; 2's complement 11101101.
- Convert binary 1100 to Gray code, and Gray code 1010 to binary.
Answer
Binary 1100 → Gray 1, 1⊕1 = 0, 1⊕0 = 1, 0⊕0 = 0 → 1010. Gray 1010 → binary 1, 1⊕0 = 1, 1⊕1 = 0, 0⊕0 = 0 → 1100.
- Add the BCD numbers 0100 0111 (47) and 0011 0101 (35).
Answer
Low digit 0111 + 0101 = 1100 (12 > 9) → add 0110 → 1 0010: digit 2, carry 1. High digit 0100 + 0011 + 1 = 1000. Result 1000 0010 = 82.
Asked in past exams · আগের পরীক্ষায় যেভাবে এসেছে
Our past papers have 48 questions on this topic (25 MCQ, 23 written) from 40 exams. Here are 12 of them; each links to its full paper.
What is the result of the binary sum 10101+1011?
- a)10000
- b)101010
- c)100000 (correct answer)
- d)111100
Explanation · ব্যাখ্যা
Correct answer: (c) 100000
Write 1011 as 01011 to line up the columns, then add from the right (1 + 1 = 10₂: write 0, carry 1):
- bit 0: 1 + 1 = 10 → write 0, carry 1
- bit 1: 0 + 1 + 1 = 10 → write 0, carry 1
- bit 2: 1 + 0 + 1 = 10 → write 0, carry 1
- bit 3: 0 + 1 + 1 = 10 → write 0, carry 1
- bit 4: 1 + 0 + 1 = 10 → write 0, carry 1
- the final carry becomes the new leftmost bit: 1
Result: 10101₂ + 1011₂ = 100000₂.
Check in decimal: 10101₂ = 21 and 1011₂ = 11, so 21 + 11 = 32 = 2⁵ = 100000₂ ✓The same check works for 11011 + 111 = 100010: 27 + 7 = 34.
Why the other options are wrong
- (a) 10000: This is 16, half the true sum: the final carry has been lost.
- (b) 101010: This is 42 = 21 × 2, i.e. 10101 shifted left one place, not 21 + 11.
- (d) 111100: This is 60, not 32.
Tip: Verify a binary sum by converting both operands and the result to decimal.
Which of the following numbers is the next sequence number of 77₈ in the octal number system?
- a)88
- b)80
- c)100 (correct answer)
- d)99
Explanation · ব্যাখ্যা
Correct answer: (c) 100
Octal (base 8) uses only the digits 0–7. Add 1 to 77₈:
- Rightmost digit: 7 + 1 = 8 = 1 × 8 + 0 → write 0, carry 1.
- Next digit: 7 + 1 (carry) = 8 → write 0, carry 1.
- The last carry becomes a new leading digit 1.
So 77₈ + 1 = 100₈.
Check in decimal: 77₈ = 7 × 8 + 7 = 63; 63 + 1 = 64 = 1 × 8² = 100₈.
Why the other options are wrong
- (a) 88: Contains the digit 8, which does not exist in base 8.
- (b) 80: Also contains the digit 8; it comes from writing 7 + 1 = 8 without carrying.
- (d) 99: Contains the digit 9, a decimal digit that is invalid in octal.
Tip: In any base, the largest n-digit number plus 1 gives 1 followed by n zeros: 7₈ + 1 = 10₈, 77₈ + 1 = 100₈, 777₈ + 1 = 1000₈.
Suppose you have an 8-bit binary number N. Which of the following operations does not change its lower 4 bits?
- a)An exclusive logical sum of N with 0Fh
- b)A logical product of N with 0Fh (correct answer)
- c)A negative logical product of N with 0Fh
- d)A logical sum of N with 0Fh
Explanation · ব্যাখ্যা
Correct answer: (b) A logical product of N with 0Fh
0Fh = 0000 1111: upper 4 bits 0, lower 4 bits 1. A logical product is a bitwise AND, and bit by bit x AND 1 = x, x AND 0 = 0. So N AND 0Fh copies the lower 4 bits of N unchanged and clears the upper 4 bits.
Example with N = A5h = 1010 0101:
- AND 0Fh → 0000 0101 (lower 4 bits 0101, unchanged)
- XOR 0Fh → 1010 1010 (lower bits inverted)
- NAND 0Fh → 1111 1010 (lower bits inverted)
- OR 0Fh → 1010 1111 (lower bits forced to 1)
A Python check over all 256 values of N confirms that only the AND leaves the lower 4 bits unchanged every time.
Why the other options are wrong
- (a) Exclusive logical sum (XOR) with 0Fh: x XOR 1 = x′, so every one of the lower 4 bits is toggled.
- (c) Negative logical product (NAND) with 0Fh: NOT(x AND 1) = x′, so the lower 4 bits are inverted (and the upper 4 become 1). Even if read as AND with the complement F0h, the lower 4 bits are cleared to 0000.
- (d) Logical sum (OR) with 0Fh: x OR 1 = 1, so the lower 4 bits are all forced to 1.
Exam note: The options print "0Fn"; this is a typo for 0Fh (h = hexadecimal), corrected here. The terms used are logical product = AND, logical sum = OR, exclusive logical sum = XOR and negative logical product = NAND.
Tip: AND with 1 keeps a bit and AND with 0 clears it; OR with 1 sets it; XOR with 1 toggles it.
Which of the following values is the correct value of this hexadecimal code 1F.01B?
- a)35.0065918
- b)32.0065918
- c)31.0065918 (correct answer)
- d)30.0065918
Explanation · ব্যাখ্যা
Correct answer: (c) 31.0065918
Multiply each hex digit by its place value (B = 11, F = 15).
Integer part 1F:
- 1 × 16¹ = 16
- 15 × 16⁰ = 15
- Total = 31
Fraction part .01B:
- 0 × 16⁻¹ = 0
- 1 × 16⁻² = 1 ÷ 256 = 0.00390625
- 11 × 16⁻³ = 11 ÷ 4096 = 0.002685546875
- Total = 27 ÷ 4096 = 0.006591796875
So 1F.01B₁₆ = 31.006591796875 ≈ 31.0065918 (rounded to 7 decimal places).
Why the other options are wrong
All four options share the same fraction, so only the integer part decides.- (a) 35.0065918: 35 = 23₁₆, not 1F₁₆.
- (b) 32.0065918: 32 = 20₁₆, one more than 1F₁₆.
- (d) 30.0065918: 30 = 1E₁₆, one less than 1F₁₆.
Tip: When the options share the fraction, convert only the integer part: 1F₁₆ = 16 + 15 = 31.
Which one of the following is equivalent hexadecimal number of (734)₈?
- a)C1D
- b)D1C
- c)1CD
- d)1DC (correct answer)
Explanation · ব্যাখ্যা
Correct answer: (d) 1DC
Convert through binary (3 bits per octal digit, then 4 bits per hex digit):
- Octal → binary: 7 = 111, 3 = 011, 4 = 100, so (734)₈ = 111 011 100₂ = 111011100₂.
- Regroup in fours from the right: 1 1101 1100 → 0001 1101 1100.
- Binary → hex: 0001 = 1, 1101 = D, 1100 = C, giving (1DC)₁₆.
Check through decimal: 7 × 64 + 3 × 8 + 4 = 448 + 24 + 4 = 476, and 1 × 256 + 13 × 16 + 12 = 256 + 208 + 12 = 476 ✓
Why the other options are wrong
- (a) C1D: = 12 × 256 + 1 × 16 + 13 = 3101, not 476.
- (b) D1C: = 13 × 256 + 1 × 16 + 12 = 3356, not 476.
- (c) 1CD: the last two digits are swapped: 1 × 256 + 12 × 16 + 13 = 461, not 476.
Tip: Octal → binary (3 bits each) → regroup 4 bits from the right → hex; no decimal step is needed.
The number of bits in the 'BCD' code used in computing is-
- a)seven bits
- b)twelve bits
- c)eighteen bits
- d)six bits (correct answer)
Explanation · ব্যাখ্যা
Correct answer: (d) six bits
Read as a character code "used in computing", BCD is the six-bit code (also called BCDIC) that IBM used on its early computers for digits, upper-case letters and some special characters. Six bits give 2⁶ = 64 code patterns: the low four bits carry the digit value, as in ordinary BCD, and two extra zone bits mark letters and symbols. IBM's later 8-bit EBCDIC (1964) was built on this code.
Why the other options are wrong
- (a) seven bits: 7 bits is the size of standard ASCII, a different character code; the BCD character code has six.
- (b) twelve bits: 12 bits is three 4-bit BCD digits (enough for 000–999), not the size of the code itself.
- (c) eighteen bits: 18 bits would be three 6-bit BCD characters; no BCD code uses 18 bits for one symbol.
Exam note: In digital logic, "BCD" normally means 8421 BCD, which uses 4 bits per decimal digit (59 → 0101 1001). 4 is not among these options, so this paper must mean the old six-bit BCD character code. If a question asks how many bits one BCD digit needs, the answer is 4.
Tip: BCD digit = 4 bits; old IBM BCD character code = 6 bits; EBCDIC = 8 bits.
Source: HyperPhysics (Georgia State University): Binary Coded Decimal; Wikipedia: BCD (character encoding)
(2019)₁₀ in Binary is________.
- a)0000011111100010
- b)0000001111110011
- c)0000001111110010
- d)0000011111100011 (correct answer)
Explanation · ব্যাখ্যা
Correct answer: (d) 0000011111100011
Divide by 2 repeatedly and read the remainders from bottom to top:
- 2019 ÷ 2 = 1009 r 1; 1009 ÷ 2 = 504 r 1; 504 ÷ 2 = 252 r 0; 252 ÷ 2 = 126 r 0
- 126 ÷ 2 = 63 r 0; 63 ÷ 2 = 31 r 1; 31 ÷ 2 = 15 r 1; 15 ÷ 2 = 7 r 1
- 7 ÷ 2 = 3 r 1; 3 ÷ 2 = 1 r 1; 1 ÷ 2 = 0 r 1
Bottom to top: 11111100011 (11 bits). Padded to 16 bits: 0000 0111 1110 0011.
Check: 1024 + 512 + 256 + 128 + 64 + 32 + 2 + 1 = 2019 ✓ (in hex, 07E3).
Why the other options are wrong
- (a) 0000011111100010: = 2018; it ends in 0, but 2019 is odd, so its last bit must be 1.
- (b) 0000001111110011: = 1011; compared with 2019 = 11111100011₂ it has one 0 missing in the middle (1111110011₂).
- (c) 0000001111110010: = 1010, and it is even, so it cannot be 2019.
Tip: An odd number always ends in 1 in binary, which rules out (a) and (c) at once.
Binary circuit elements have
- a)One stable state
- b)Two stable states (correct answer)
- c)Three stable states
- d)None of these
Explanation · ব্যাখ্যা
Correct answer: (b) Two stable states
A binary circuit element has to hold one of two values, 0 or 1, and keep it until it is deliberately changed. Such an element is called a bistable: it has exactly two stable states, for example a low and a high output voltage. Latches and flip-flops are the standard bistable elements, and each stores one bit. Feedback inside the circuit holds whichever state was last set.
Why the other options are wrong
- (a) One stable state: A circuit with only one stable state (a monostable) always returns to that state, so it cannot remember which of two values it was given and cannot hold a bit.
- (c) Three stable states: Three states would make a ternary (base-3) element. Binary means base 2, so there are exactly two states. A tri-state output's third condition is a disconnected (high-impedance) output, not a third logic value.
- (d) None of these: Option (b) is correct.
Tip: Binary element = bistable = two stable states = 1 bit.
Sources: University of Cambridge, Digital Electronics: Sequential Logic, introduction, latches and flip-flops (slides); MIT 6.191 (Fall 2023), L06: Sequential Circuits and Finite State Machines (slides)
What is the Hexadecimal form of (2016)₁₀?
- a)5A0
- b)7A0
- c)5E0
- d)7E0 (correct answer)
Explanation · ব্যাখ্যা
Correct answer: (d) 7E0
Convert by repeated division by 16, keeping the remainders:
- 2016 ÷ 16 = 126, remainder 0
- 126 ÷ 16 = 7, remainder 14 = E
- 7 ÷ 16 = 0, remainder 7
Read the remainders from the last to the first: (2016)₁₀ = (7E0)₁₆.
Check: 7 × 256 + 14 × 16 + 0 × 1 = 1792 + 224 + 0 = 2016.
Why the other options are wrong
- (a) 5A0: 5 × 256 + 10 × 16 = 1280 + 160 = 1440, not 2016.
- (b) 7A0: 7 × 256 + 10 × 16 = 1792 + 160 = 1952; the middle digit should be E (14), not A (10).
- (c) 5E0: 5 × 256 + 14 × 16 = 1280 + 224 = 1504; the leading digit should be 7.
Tip: Check any hex answer by multiplying back: first digit × 256, second × 16, last × 1.
(a) Convert the numbers (16A.6)₁₆ and (72.3)₈ in binary format and show their summation in Hexadecimal format.
What is the hexadecimal value of (1111011011)₂?
The number of states in a 4-bit BCD ripple counter is:
Common mistakes · সাধারণ ভুল
- Reading division remainders top to bottom: the integer part is read from the last remainder upward (fraction digits are read downward).
- Writing BCD as pure binary: 59 in BCD is 0101 1001, not 111011.
- Forgetting to add 1 for the 2's complement (that gives the 1's complement), or forgetting to drop the final carry after subtraction by addition.
- Giving the 8-bit signed range as −127 to +127: in 2's complement it is −128 to +127 (−127 to +127 is sign-magnitude or 1's complement).
- Converting octal to hex digit by digit: go through binary and regroup (734₈ = 1DC₁₆).
- Calling ASCII an 8-bit code: standard ASCII is 7 bits (128 characters); 8-bit sets are extensions.
বাংলায় সংক্ষেপে
- বাইনারির ভিত্তি ২, অক্টালের ৮, ডেসিমেলের ১০, হেক্সাডেসিমেলের ১৬ (A = ১০ … F = ১৫); কম্পিউটার বাইনারিতে কাজ করে, কারণ এর বর্তনীর দুটি স্থির অবস্থা।
- দশমিকে নিতে অঙ্ক × স্থানীয় মান যোগ; দশমিক থেকে নিতে ভিত্তি দিয়ে বারবার ভাগ (ভাগশেষ নিচ থেকে ওপরে), ভগ্নাংশে বারবার গুণ (ওপর থেকে নিচে)।
- অক্টালের একটি অঙ্ক = ৩ বিট, হেক্সের একটি অঙ্ক = ৪ বিট; অক্টাল থেকে হেক্সে যেতে বাইনারির মাধ্যমে যেতে হয়, যেমন (৭৩৪)₈ = (1DC)₁₆।
- ২-এর পরিপূরক = সব বিট উল্টে ১ যোগ; n বিটে পরিসর −২ⁿ⁻¹ থেকে ২ⁿ⁻¹ − ১; ৮ বিটে ১১১১১১১১ = −১ এবং ১০০০০০০০ = −১২৮।
- বিসিডি-তে প্রতিটি দশমিক অঙ্ক ৪ বিটে (৫৯ = ০১০১ ১০০১); যোগফল ৯-এর বেশি হলে ০১১০ যোগ করতে হয়; এক্সেস-৩ = বিসিডি + ৩।
- গ্রে কোডে পাশাপাশি সংখ্যায় একটি বিট বদলায়; বাইনারি ১০১১ = গ্রে ১১১০।
- অ্যাসকি ৭ বিটের (১২৮টি ক্যারেক্টার, A = ৬৫, a = ৯৭); ইউনিকোডের ইউটিএফ-৮ এক থেকে চার বাইট ব্যবহার করে (বাংলা অক্ষরে তিন বাইট); প্যারিটি বিট একটি বিটের ভুল ধরে, দুটি বিটের ভুল ধরতে পারে না।
Sources
- MIT OpenCourseWare 6.004: Computation Structures (binary representation, two's complement), Spring 2017
- RFC 20: ASCII format for Network Interchange, 1969
- The Unicode Standard, latest version (Unicode Consortium)
- RFC 3629: UTF-8, a transformation format of ISO 10646, 2003
- NIST Dictionary of Algorithms and Data Structures: Gray code
- UC Berkeley CS61C course notes: integer representations (sign-magnitude, one's and two's complement, bias)
- UC Berkeley CS61C course notes: IEEE 754 floating point (1 sign, 8 exponent, 23 significand bits, bias 127)
- Columbia University Computing History: the IBM 1620, a decimal computer
Updated 2026-10-18. Written by ARBS Academy; the past exam questions are from public recruitment exams.