Conversion of Decimal to Binary and Binary to Decimal

Decimal to binary: बार बार 2 से divide करो और remainders को नीचे से ऊपर पढ़ो; binary to decimal: हर bit को उसके power of 2 से multiply करके जोड़ 2।

10 min read · 10 cards · 2 checks

Read in: English · हिन्दी · ગુજરાતી


Theory

25 को computer के तरीके से लिखिए

Chirag दुकान के whiteboard पर 25 लिखता है और marker आपको पकड़ा देता है: "ये तो इंसान के लिखने का तरीका है। मुझे बताओ machine इसे कैसे store करती है।"

Machine के अंदर तो सिर्फ switches हैं: on, off, on... तो 25 को भी 1s और 0s की एक line में बदलना पड़ेगा।

2 mechanical recipes हैं जो दोनों direction में convert करती हैं, और सच बताऊँ तो पूरे subject में ये सबसे guaranteed marks वाला हिस्सा है: बस पक्का method चाहिए, theory का कोई झंझट नहीं जो भूल जाओ।

Follow along

Decimal → binary: नीचे की तरफ divide करो, ऊपर की तरफ पढ़ो

  1. Number को 2 से divide करो Quotient नीचे लिखो, और remainder (0 या 1) उसके बगल में लिखो।
  2. हर quotient को फिर 2 से divide करते रहो हर step में remainder या तो 0 आएगा या 1। ये तब तक चलाते रहो जब तक quotient 0 न हो जाए।
  3. Remainders को नीचे से ऊपर पढ़ो जो सबसे आखिरी remainder है वही सबसे बाईं (leftmost) bit बनेगा। यहीं पर ज्यादातर students के marks कटते हैं।
  4. Answer को वापस convert करके verify करो 30 second का positional sum हर छोटी गलती पकड़ लेता है।

Theory

Solve करके देखिए: 25 → binary

25 ÷ 2 = 12 remainder 1

12 ÷ 2 = 6 remainder 0

6 ÷ 2 = 3 remainder 0

3 ÷ 2 = 1 remainder 1

1 ÷ 2 = 0 remainder 1

अब remainder वाली column को नीचे से ऊपर पढ़िए: 11001।

तो 25 = 11001₂। अब सवाल ये कि नीचे से ऊपर क्यों? देखिए, पहला remainder बताता है कि number odd है या even, और वही तो आखिरी (rightmost) bit होती है। हर अगली division बड़े chunks पर काम करती है, इसलिए वो more significant bits बनाती है।

Theory

Binary → decimal: power की सीढ़ी

उल्टी direction तो पिछले topic का वही positional rule है। Bits के ऊपर powers of 2 लिख दीजिए, दाएँ से बाएँ: 1, 2, 4, 8, 16, 32, 64, 128...

bits: 1 1 0 0 1

power: 16 8 4 2 1

जहाँ जहाँ 1 है उसके नीचे वाली power जोड़ 2, 0 वालों को छोड़ दो:

16 + 8 + 1 = 25 ✓

वही number वापस आ गया, और यही तो वो verification की आदत है जो steps में बताई थी: exam में conversion का हर answer इस round trip से गुज़रना चाहिए।

Think first

अब आपकी बारी: 13

कागज़ पर 13 को binary में convert कीजिए, division method से। फिर अपने answer को power की सीढ़ी से वापस convert कीजिए। Reveal करने से पहले दोनों काम कर लीजिए।

Show the answer

13 ÷ 2 = 6 r 1; 6 ÷ 2 = 3 r 0; 3 ÷ 2 = 1 r 1; 1 ÷ 2 = 0 r 1

नीचे से ऊपर: 1101।

Check: 8 + 4 + 0 + 1 = 13 ✓

अगर आपका answer 1011 आया, तो आपने remainders ऊपर से नीचे पढ़ लिए, यही conversion की सबसे common गलती है। याद रखिए: divide नीचे की तरफ, पढ़ो ऊपर की तरफ।

Quiz

1010₂ का decimal में मान क्या है?

  1. 10
  2. 5
  3. 20
  4. 101
Show the answer

10

Bits के नीचे powers रखिए: 8, 4, 2, 1। 1 बैठे हैं 8 और 2 पर, तो 8 + 2 = 10। अगर आपने 5 चुना तो आपने bits उल्टी पढ़ीं (0101), और 101 का मतलब है आपने binary को ऐसे treat किया जैसे वो पहले से ही decimal हो। हर बार, बिना नागा, bits के ऊपर power की सीढ़ी रखिए।

Watch out

2 marks खाने वाली गलतियाँ

Remainders को ऊपर से नीचे पढ़ना: इससे बिल्कुल उल्टा mirror answer आता है; method है divide नीचे की तरफ, पढ़ो ऊपर की तरफ। सीढ़ी पर फिसल जाना: 1, 2, 4, 8, 16, 32, 64, 128 इतना रटो कि ज़बान पर चढ़ जाए; एक power भी गलत हुई तो पूरा sum खराब। Exam में division table ज़रूर दिखाइए, ताकि आखिरी arithmetic में छोटी गलती हो जाए तब भी method marks बच जाएँ।

Formula

Exam की recipe

"convert X to binary" वाले सवाल में: remainder column के साथ division table लिखिए, नीचे से ऊपर पढ़कर remainders को box कीजिए, फिर एक verification line लगाइए जो वापस convert करके दिखाए। "convert bits to decimal" वाले में: bits के ऊपर power की सीढ़ी लिखिए, 1 के नीचे वाली powers जोड़ दीजिए। ये दोनों format बिल्कुल वही हैं जिनको examiner पूरे method marks देता है।

Theory

ये आपको बार बार काम आएगा

अगला topic इन्हीं bit-strings को add और subtract करेगा, यही तो ALU का रोज़ का काम है। Address-bus का 2ⁿ rule, ASCII codes, networking में subnet masks (Sem 5), यहाँ तक कि colour #FF5733 भी: ये सब readable हो जाते हैं जब conversions reflex बन जाएँ। इतनी practice कीजिए कि 0 से 31 तक के numbers पुराने दोस्तों जैसे लगें।

Summary

Key takeaways

  • Decimal → binary: बार बार 2 से divide करो, remainders को नीचे से ऊपर पढ़ो।
  • Binary → decimal: power की सीढ़ी (1,2,4,8,16,...), 1 के नीचे वाली powers जोड़ 2।
  • हमेशा reverse conversion से verify करो, इसमें बस 30 second लगते हैं।
  • पहला remainder ही rightmost bit होता है (odd/even test)।
  • Division table दिखाइए: arithmetic में गलती हो जाए तब भी method marks बच जाते हैं।
  • Memory hook: divide नीचे की तरफ, पढ़ो ऊपर की तरफ।

Study this properly

This page is the lesson to read. In Gri-Learn the same topic is a graded deck: the self-checks are scored and your weak topics are tracked. Free to start.

Start this topic

Already have an account? Sign in

More from Basic Computer Architecture

Gri-Learn · syllabus-mapped B.C.A. lessons in English, Hindi and Gujarati

Conversion of Decimal to Binary and Binary to Decimal · Introduction to Computers · Gri-Learn