Free tutorials & notes in Hindi & English · Clean code examples 🧰 मुफ़्त PDF और फ़ोटो टूल्स →
🖥️ Unit 1 – Computer System और Organisation  ·  Lesson 05

Number System Conversions

Conversion map

बस दो बड़े तरीके हैं। Decimal से किसी दूसरे base में जाने के लिए बार-बार divide करें। Decimal में आने के लिए place values से multiply करके जोड़ें। Binary, octal और hex के बीच तेज़ grouping shortcuts हैं।

Decimalbase 10÷ 2Binarybase 2group bitsOctal / Hexbase 8 / 16
Decimal → बाकी: repeated division · बाकी → decimal: place values · Binary ↔ octal/hex: 3 / 4 के groups

Decimal → binary, octal या hexadecimal

Rule: decimal number को नए base से divide करें, remainder लिखें, quotient को फिर divide करें, और quotient 0 होने तक चलते रहें। Remainders नीचे से ऊपर पढ़ें।

Example 1: (156)₁₀ → binary

DivideQuotientRemainder
156 ÷ 2780
78 ÷ 2390
39 ÷ 2191
19 ÷ 291
9 ÷ 241
4 ÷ 220
2 ÷ 210
1 ÷ 201
Remainders ऊपर की ओर पढ़ें: (156)₁₀ = (10011100)₂

Example 2: (156)₁₀ → octal

156 ÷ 8 = 19 remainder 4; 19 ÷ 8 = 2 remainder 3; 2 ÷ 8 = 0 remainder 2। ऊपर की ओर: (234)₈।

Example 3: (156)₁₀ → hexadecimal

156 ÷ 16 = 9 remainder 12 = C; 9 ÷ 16 = 0 remainder 9। ऊपर की ओर: (9C)₁₆।

⚠️ आम ग़लती

Hex में 10–15 का remainder letter A–F के रूप में लिखें, दो digits में नहीं। 156 को "912" लिखना ग़लत है; सही 9C है।

किसी भी base → decimal

Rule: हर digit को baseposition (दाईं ओर position 0) से multiply करें और सब जोड़ दें।

NumberExpansionDecimal
(10011100)₂1×128 + 0×64 + 0×32 + 1×16 + 1×8 + 1×4 + 0×2 + 0×1156
(234)₈2×64 + 3×8 + 4×1156
(9C)₁₆9×16 + 12×1156
(1011.1)₂8 + 0 + 2 + 1 + 1×2⁻¹11.5
तीनों numbers की value एक ही है: 156

Point के बाद वाले digits की positions negative होती हैं: −1, −2 … इसलिए binary में weights ½ = 0.5, ¼ = 0.25, ⅛ = 0.125 … हैं।

Decimal fractions → binary

Rule: fractional part को 2 से multiply करें। Integer part (0 या 1) अगली bit है। सिर्फ़ fraction रखें और दोहराएँ। Bits ऊपर से नीचे पढ़ें।

StepMultiplyResultBit
10.625 × 21.251
20.25 × 20.50
30.5 × 21.01
40.0 – stop
(0.625)₁₀ = (0.101)₂
Python
x = 0.625
bits = ''
for step in range(4):
    x = x * 2
    bits += str(int(x))      # integer part is the next bit
    x = x - int(x)
print('0.' + bits)
0.1010

इसलिए (12.625)₁₀ = (1100.101)₂ — integer part को division से और fraction को multiplication से बदलें, फिर दोनों जोड़ दें।

Binary ↔ octal (3 के groups)

Binary → octal: दाईं ओर से 3-3 bits के groups बनाएँ (ज़रूरत हो तो बाईं ओर 0 जोड़ें) और हर group की value लिखें।

10011100 →010011100
दाईं ओर से 3 के groups → 2 3 4 → (234)₈

Octal → binary: हर octal digit को 3 bits में लिखें। (57)₈ → 101 111 → (101111)₂।

Binary ↔ hexadecimal (4 के groups)

Binary → hex: दाईं ओर से 4 bits के groups। (10011100)₂ → 1001 1100 → 9 C → (9C)₁₆।

1010111111 →001010111111
बाईं ओर zeros जोड़ें: 0010 1011 1111 → 2 B F → (2BF)₁₆

Hex → binary: हर hex digit 4 bits बनता है। (A7)₁₆ → 1010 0111 → (10100111)₂।

Octal ↔ hexadecimal

सीधा shortcut नहीं है, इसलिए बीच में binary use करें।

(345)₈octal011 100 101हर digit 3 bits1110 01014 के groups(E5)₁₆hex
Octal → binary → hexadecimal

उल्टा example: (B2)₁₆ → 1011 0010 → 3 के groups: 010 110 010 → (262)₈।

Python में अपना converter

यह program वही repeated-division तरीका use करता है जो आप paper पर करते हैं — % remainder देता है, // quotient।

Python
def to_base(n, base):
    digits = '0123456789ABCDEF'
    if n == 0:
        return '0'
    result = ''
    while n > 0:
        result = digits[n % base] + result   # remainder becomes next digit
        n = n // base
    return result

for b in (2, 8, 16):
    print(156, 'in base', b, '=', to_base(156, b))
156 in base 2 = 10011100 156 in base 8 = 234 156 in base 16 = 9C

और उल्टा, place-value तरीके से (Horner's तरीका: चल रही value को base से multiply करके अगला digit जोड़ें):

Python
def to_decimal(text, base):
    digits = '0123456789ABCDEF'
    value = 0
    for ch in text.upper():
        value = value * base + digits.index(ch)
    return value

print(to_decimal('10011100', 2))
print(to_decimal('234', 8))
print(to_decimal('9C', 16))
156 156 156

सारांश और practice

  • Decimal → base b: b से divide, remainders ऊपर की ओर।
  • Base b → decimal: Σ digit × bposition।
  • Fraction → binary: 2 से multiply, integer parts नीचे की ओर।
  • Binary ↔ octal: 3 के groups; binary ↔ hex: 4 के groups; octal ↔ hex binary से होकर।
✅ Practice

1) (99)₁₀ = (?)₂ 2) (110110)₂ = (?)₁₆ 3) (725)₈ = (?)₁₀ 4) (3F)₁₆ = (?)₈ 5) (0.75)₁₀ = (?)₂

Answers: 1) 1100011 2) 36 3) 469 4) 77 5) 0.11

अक्सर पूछे जाने वाले प्रश्न (FAQ)

Decimal को binary में जल्दी कैसे बदलें?
Number को बार-बार 2 से divide करें और remainders लिखें। Remainders नीचे से ऊपर पढ़ें। जैसे 13 → remainders 1,0,1,1 → 1101।
Octal को hexadecimal में कैसे बदलें?
Binary से होकर। हर octal digit को 3 bits में लिखें, फिर bits को दाईं ओर से चार-चार के groups में बाँटें और हर group का hex digit लिखें।
Remainders नीचे से ऊपर क्यों पढ़ते हैं?
पहला remainder इकाई (least significant digit) है। हर अगला remainder ऊँची place है, इसलिए आख़िरी remainder most significant digit है और सबसे पहले लिखा जाता है।
← Class 11 Computer Science
🔗

Share this topic with a friend

यह topic किसी दोस्त को भेजें

Found it useful? Send it to a classmate learning the same thing.

अच्छा लगा? जो दोस्त यही सीख रहा है, उसे भेज दीजिए।

अगला topicEncoding: ASCII, ISCII और Unicode आपकी प्रगति: 5 / 29 (17%) · Lesson 6 / 29 आगे बढ़ें →

यह lesson कैसा लगा?

आपकी राय से हम content और बेहतर बनाते हैं।

अपना review और सुझाव लिखें (वैकल्पिक)

Review approve होने के बाद आपका नाम और शहर इसके साथ public दिख सकते हैं। Email या phone न लिखें।

▶ CodingEasily on YouTube

Video से सीखें – आसान Hindi में

चुनी हुई video: RDBMS भाग 3 – Class XI Commerce IT

▶ Channel subscribe करें