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
- 73
- Papers
- 56
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.
How often it is asked · কতবার এসেছে
Number Systems & Codes came up 73 times in 56 of our papers, from 2015 to 2026: 45 MCQ and 28 written. Papers for Government IT officer posts ask it most (24), then Bank IT jobs (21). 17 of those questions are from 2025–2026 papers.
- Years covered
- 2015–2026
- MCQ / written
- 45 / 28
- MCQs asked again
- 2
By exam · পরীক্ষাভিত্তিক
Questions on Number Systems and Codes in each exam's papers
- Government IT officer posts2432.9%
- Bank IT jobs2128.8%
- BPSC non-cadre IT posts1115.1%
- BCS (ICT and CSE cadre)811.0%
- ICT teaching posts (NTRCA)56.8%
- M.Sc. admission (CSE and ICT)45.5%
By year · বছরভিত্তিক
The 8 newest exam years in our papers
- 20264
- 202513
- 20247
- 20233
- 202211
- 202111
- 20209
- 20196
Asked in more than one exam · একাধিক পরীক্ষায় এসেছে
2 MCQs in this topic came back word for word in a second exam; the 2 most repeated technical ones below, each linked to the papers.
বাইনারি পদ্ধতির যোগে 1+1+1 = কত?
Digital Logic, asked in 2 exams:BDCCL Assistant Manager 2022BDCCL Assistant Manager 2022
Suppose you have an 8-bit binary number N. Which of the following operations does not change its lower 4 bits?
Digital Logic, asked in 2 exams:Sonali Bank Senior Officer Oct 2021Bank Assistant Programmer Mar 2021
Counted from our own past papers: every past-exam MCQ and written question, each filed under one syllabus chapter. Practice questions and questions held for live tests are not counted; no answer is shown here.
Asked in past exams · আগের পরীক্ষায় যেভাবে এসেছে
Our past papers have 73 questions on this topic (45 MCQ, 28 written) from 56 exams. Here are 12 of them; each links to its full paper.
Convert (1E.53)_16 to the Octal system (?)_8:
- a)(36.256)_8
- b)(37.246)_8
- c)(35.246)_8
- d)(36.246)_8 (correct answer)
Explanation · ব্যাখ্যা
Correct answer: (d) (36.246)_8
- Hex → binary (4 bits each): 1 = 0001, E = 1110, 5 = 0101, 3 = 0011 → 11110.01010011.
- Integer part, group 3 bits leftwards from the point: 011 110 → 3 6.
- Fraction, group 3 bits rightwards, pad a zero: 010 100 110 → 2 4 6.
- Result: (36.246)_8.
- Check: 1E.53₁₆ = 30 + 83/256 = 30.32421875; 36.246₈ = 30 + 2/8 + 4/64 + 6/512 = 30.32421875.
Other options: (a) (36.256)_8 — middle fraction group is 100 = 4, not 5 (its value is 30.33984375); (b) (37.246)_8 — 37₈ = 31, but 1E₁₆ = 30; (c) (35.246)_8 — 35₈ = 29, off by one.
Also know:
- Hex ↔ octal is easiest through binary: 4-bit groups for hex, 3-bit groups for octal.
- Pad with zeros only at the outer ends: left of the integer part, right of the fraction.
- Python's float.fromhex('1E.53') returns 30.32421875, a quick check.
Sources: float.fromhex – Python documentation
Convert: (123.4) = (?)₁₆
- a)(7B.4)₁₆
- b)(7B.6)₁₆ (correct answer)
- c)(123.6)₁₆
- d)(7C.6)₁₆
Explanation · ব্যাখ্যা
Correct answer: (b) (7B.6)₁₆
Taking (123.4) as a decimal number, convert the two parts separately.
Integer part (divide by 16, read remainders bottom-up):
123 ÷ 16 = 7 remainder 11 (B); 7 ÷ 16 = 0 remainder 7 → 7B₁₆ (check: 7×16 + 11 = 123)Fraction part (multiply by 16, read integer parts top-down):
0.4 × 16 = 6.4 → 6; 0.4 × 16 = 6.4 → 6; … the 6 repeats for everSo 123.4₁₀ = 7B.666…₁₆, which is 7B.6₁₆ to one hex place (rounding also gives 6, because the remainder 0.4 is below one half). Check: 7B.6₁₆ = 123 + 6/16 = 123.375.
Why the other options are wrong
- (a) (7B.4)₁₆: It copies the decimal digit 4 into the fraction; 0.4₁₀ is not 0.4₁₆ (0.4₁₆ = 4/16 = 0.25).
- (c) (123.6)₁₆: It copies the decimal integer digits; 123₁₆ = 291₁₀, not 123.
- (d) (7C.6)₁₆: The integer part is off by one: 7C₁₆ = 124.
Exam note: The stem does not print the base of (123.4); it must be decimal, the only reading that matches any option (as octal, 123.4₈ = 83.5₁₀ = 53.8₁₆). The exact hex value never ends (7B.666…₁₆); option (b) gives it to one hex place.
Tip: Integer part: divide by 16, read remainders upward. Fraction: multiply by 16, read integer parts downward.
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.
- MCQ · 2023BREB — Assistant Programmer — Exam: 2023
(2023)₁₀ = (?)₁₆
- a)7E0
- b)7D0
- c)8E0
- d)7E7 (correct answer)
Explanation · ব্যাখ্যা
Correct answer: (d) 7E7
Repeated division by 16, keeping the remainders:
- 2023 ÷ 16 = 126, remainder 7
- 126 ÷ 16 = 7, remainder 14 (= E)
- 7 ÷ 16 = 0, remainder 7
Reading the remainders from bottom to top: (2023)₁₀ = (7E7)₁₆.
Check: 7 × 16² + 14 × 16 + 7 = 1792 + 224 + 7 = 2023 ✓The same method turns 1971 into 7B3: 7 × 256 + 11 × 16 + 3 = 1792 + 176 + 3 = 1971.
Why the other options are wrong
- (a) 7E0: 7 × 256 + 14 × 16 + 0 = 2016, which is 7 short.
- (b) 7D0: 7 × 256 + 13 × 16 + 0 = 2000.
- (c) 8E0: 8 × 256 + 14 × 16 + 0 = 2272.
Tip: Always multiply back (digit × 16ᵏ) to confirm a hex conversion.
বিসিডি কোডে বিট সংখ্যা কত?
- a)1
- b)2
- c)8
- d)4 (correct answer)
Explanation · ব্যাখ্যা
সঠিক উত্তর: (d) 4
BCD (Binary Coded Decimal) পদ্ধতিতে দশমিক সংখ্যার প্রতিটি অঙ্ক আলাদা একটি 4-বিট গ্রুপে লেখা হয়, আর বিটগুলোর ওজন 8, 4, 2, 1 (তাই একে 8421 কোডও বলে)। ১০টি অঙ্ক (0–9) আলাদা করতে কমপক্ষে ১০টি কোড লাগে: 2³ = 8টি কোড কম পড়ে, 2⁴ = 16টি কোড যথেষ্ট। উদাহরণ: 7 = 0111, আর 25 = 0010 0101। বাকি ৬টি কোড (1010–1111) BCD-তে ব্যবহৃত হয় না।
অন্য অপশনগুলো কেন ভুল
- (a) 1: এক বিটে কেবল 0 আর 1, অর্থাৎ ২টি মান; ১০টি অঙ্কের জন্য যথেষ্ট নয়।
- (b) 2: 2 বিটে 2² = 4টি কোড, যা 0–9-এর জন্য কম।
- (c) 8: 8 বিট (এক byte)-এ 4 বিট করে দুটি BCD অঙ্ক ধরে; এক অঙ্কের জন্য 8 বিট লাগে না।
পরীক্ষার নোট: উত্তরটি প্রচলিত 8421 BCD ধরে দেওয়া হয়েছে (প্রতি অঙ্কে 4 বিট)। কিছু পুরোনো প্রশ্নে BCD-র বিট সংখ্যা ৬ ধরা হয়; সেটি আগের IBM কম্পিউটারে ব্যবহৃত 6-বিট BCD character code (BCDIC), যা অক্ষরও প্রকাশ করত। প্রশ্নে character code-এর কথা না থাকলে 4 বিটই সঠিক।
টিপ: BCD = প্রতি দশমিক অঙ্কে 4 বিট; 1010 থেকে 1111 অবৈধ।
উৎস: HyperPhysics (Georgia State University): Binary Coded Decimal; Wikipedia: BCD (character encoding)
বিসিডি কোডে বিট সংখ্যা কত?
- a)১
- b)২
- c)৮
- d)৪ (correct answer)
Explanation · ব্যাখ্যা
সঠিক উত্তর: (d) ৪
BCD (Binary Coded Decimal) কোডে পুরো সংখ্যাকে একসাথে binary-তে রূপান্তর করা হয় না; দশমিক সংখ্যার প্রতিটি অঙ্ককে আলাদাভাবে binary-তে লেখা হয়। দশমিক অঙ্ক মোট ১০টি (0–9)। 3 বিটে মাত্র 2³ = 8টি কোড পাওয়া যায়, যা ১০টি অঙ্কের জন্য যথেষ্ট নয়; 4 বিটে পাওয়া যায় 2⁴ = 16টি কোড। তাই প্রচলিত 8421 BCD-তে প্রতিটি অঙ্কের জন্য 4 বিট লাগে। যেমন 59 = 0101 1001। 16টি কোডের মধ্যে 1010 থেকে 1111 পর্যন্ত ৬টি কোড BCD-তে অবৈধ।
অন্য অপশনগুলো কেন ভুল
- (a) ১: 1 বিটে মাত্র 2টি মান (0 ও 1) প্রকাশ করা যায়, ১০টি অঙ্ক নয়।
- (b) ২: 2 বিটে 2² = 4টি কোড পাওয়া যায়; 0–9 প্রকাশের জন্য তা যথেষ্ট নয়।
- (c) ৮: 8 বিট মানে এক byte, যাতে 4 বিট করে দুটি BCD অঙ্ক রাখা যায়। একটি অঙ্কের জন্য 8 বিট দরকার হয় না।
পরীক্ষার নোট: এখানে "BCD কোড" বলতে প্রচলিত 8421 BCD ধরা হয়েছে, যেখানে প্রতি দশমিক অঙ্কে 4 বিট। কোনো কোনো প্রশ্নে BCD-র বিট সংখ্যা "৬" লেখা থাকে; সেটি পুরোনো IBM কম্পিউটারের 6-বিট BCD character code (BCDIC) বোঝায়, যা অঙ্কের পাশাপাশি অক্ষরও প্রকাশ করত। প্রশ্নে স্পষ্টভাবে character code না বললে উত্তর 4 বিট।
টিপ: BCD-তে এক দশমিক অঙ্ক = 4 বিট (এক nibble); 1010–1111 অবৈধ।
উৎস: HyperPhysics (Georgia State University): Binary Coded Decimal; Wikipedia: BCD (character encoding)
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.
2's complement of 00000000 is:
- a)11111111
- b)10000000
- c)00000000 (correct answer)
- d)00000001
Explanation · ব্যাখ্যা
Correct answer: (c) 00000000
2's complement = invert every bit, then add 1, keeping the original word length (8 bits).
- Number: 00000000
- Invert every bit (1's complement): 11111111
- Add 1: 11111111 + 1 = 1 00000000 (9 bits)
- Keep 8 bits; the carry out of bit 7 is discarded: 00000000
So the 2's complement of 0 is 0. This is why 2's complement has only one zero, unlike sign-magnitude and 1's complement, which have both +0 and −0.
The same rule turns 00101100 (+44) into 11010100 (−44), and adding the two gives 1 00000000, which is 0 once the carry is dropped.
Why the other options are wrong
- (a) 11111111: this is only the 1's complement (step 2); the +1 is missing. In 8-bit 2's complement, 11111111 means −1.
- (b) 10000000: this is −128, the most negative 8-bit value. It is not related to 0.
- (d) 00000001: this is +1; it comes from adding 1 without inverting the bits first.
Tip: In n-bit 2's complement, only two patterns are their own 2's complement: 0 (00000000) and −2ⁿ⁻¹ (10000000 for n = 8).
Among the following, which is not a divisor of (1001011011110000000)₂?
- a)(2)₁₀
- b)(64)₁₀
- c)(128)₁₀
- d)(256)₁₀ (correct answer)
Explanation · ব্যাখ্যা
Correct answer: (d) (256)₁₀
In binary, each trailing 0 is one factor of 2. The number 1001011011110000000₂ ends in exactly 7 zeros (…1111 0000000), and the bit before them is 1. So it equals 2⁷ × (an odd number):
1001011011110000000₂ = 309120 = 2⁷ × 2415, and 2415 is odd.
It is therefore divisible by 2¹ up to 2⁷ = 128, but not by 2⁸ = 256: 309120 ÷ 256 = 1207.5.
Why the other options are wrong
- (a) (2)₁₀: 2 = 2¹ needs one trailing zero; there are 7. 309120 ÷ 2 = 154560.
- (b) (64)₁₀: 64 = 2⁶ needs six trailing zeros; there are 7. 309120 ÷ 64 = 4830.
- (c) (128)₁₀: 128 = 2⁷ needs seven trailing zeros; there are exactly 7. 309120 ÷ 128 = 2415.
Tip: k trailing zeros in binary → divisible by 2ᵏ, but not by 2ᵏ⁺¹ when the next bit is 1.
(B12)₁₆+(5CA)₁₆=?
- a)(10DC)₁₆ (correct answer)
- b)(AFDC)₁₆
- c)(1FDC)₁₆
- d)(E1DC)₁₆
Explanation · ব্যাখ্যা
Correct answer: (a) (10DC)₁₆
Add column by column from the right, carrying 1 whenever a column reaches 16:
- 2 + A = 2 + 10 = 12 = C, carry 0
- 1 + C = 1 + 12 = 13 = D, carry 0
- B + 5 = 11 + 5 = 16 = 10₁₆ → write 0, carry 1
- The final carry 1 becomes the leading digit.
Result: (B12)₁₆ + (5CA)₁₆ = (10DC)₁₆.
Decimal check: B12₁₆ = 11 × 256 + 1 × 16 + 2 = 2834; 5CA₁₆ = 5 × 256 + 12 × 16 + 10 = 1482; 2834 + 1482 = 4316 = 1 × 4096 + 0 × 256 + 13 × 16 + 12 = 10DC₁₆ ✓
Why the other options are wrong
- (b) (AFDC)₁₆: = 45020, far larger than the true sum 4316.
- (c) (1FDC)₁₆: = 8156; it writes F in the third column instead of 0 (B + 5 = 16 must become 0 with a carry).
- (d) (E1DC)₁₆: = 57820, also far too large.
Tip: In hex, a column sum of 16 or more → subtract 16, write the remainder, carry 1.
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.