Number System: Decimal, Binary, Octal and Hexadecimal

हर number system उसके base से पहचाना जाता है (मतलब उसमें कितने symbols हैं); computers binary (base 2) use करते हैं क्योंकि circuits सिर्फ ON और OFF समझते हैं, और octal तथा hex उसके short forms हैं।

10 min read · 10 cards · 2 checks

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


Theory

Chirag की T-shirt वाला joke

Chirag की Friday वाली T-shirt पर लिखा है: "There are 10 kinds of people: those who understand binary and those who don't."

Customer हँस तो देता है politely, पर उसे समझ नहीं आता। आपको आ जाएगा, बस 4 मिनट में।

असली मज़ा इसमें ये है: ये जो "10" लिखा है, इसका मतलब हमेशा 10 नहीं होता। किसी numeral का क्या मतलब है, ये इस बात पर depend करता है कि वो किस system में लिखा गया है, और computer आपसे बिल्कुल अलग system use करता है।

Theory

Circuits 2 में क्यों गिनते हैं

दुकान का कोई भी switch देख लीजिए: ON या OFF। कोई आधा-on नहीं होता। Computer तो लाखों छोटे-छोटे switches (transistors) से बना है, इसलिए उसकी natural alphabet में बस 2 ही अक्षर हैं: current बह रहा है = 1, नहीं बह रहा = 0। अगर किसी circuit से बोलें कि reliably 10 अलग-अलग voltage levels पकड़कर रखो, तो errors ही आएँगे; 2 states साफ-सुथरी भी हैं और सस्ती भी। बस यही एक कारण है कि binary exist करता है।

Theory

हर system के नीचे छुपा एक ही rule

ये सारे systems positional होते हैं: किसी digit की value = digit × (base की उसकी position वाली power), और positions दाईं तरफ से 0 से गिनी जाती हैं।

ये तो आप decimal में बिना सोचे-समझे already कर ही रहे हैं:

452 = 4·10² + 5·10¹ + 2·10⁰ = 400 + 50 + 2

वही rule, अब base 2 में:

101₂ = 1·2² + 0·2¹ + 1·2⁰ = 4 + 0 + 1 = 5

तो binary का "10" = 1·2 + 0 = 2। T-shirt कह रही है "there are TWO kinds of people"। और अब आप पहली category में आ गए।

At a glance

Exam में आने वाले 4 systems

SystemBaseSymbolsकहाँ मिलते हैं
Decimal100 to 9रोज़मर्रा की ज़िंदगी, पैसों में
Binary20, 1Computer के अंदर सब जगह
Octal80 to 7Unix file permissions, पुराने systems
Hexadecimal160-9 और A-FColour codes, MAC addresses

Theory

Hex: binary का short form

Base 16 को सोलह symbols चाहिए, तो 9 के बाद वो letters उधार ले लेता है: A=10, B=11, C=12, D=13, E=14, F=15।

इतना झंझट क्यों? क्योंकि एक hex digit = exactly 4 binary bits, तो लंबी-लंबी bit-strings बड़े साफ तरीके से छोटी हो जाती हैं:

1111 1111₂ = FF₁₆ = 255

Hex तो आपने ज़िंदगी भर देखा है: किसी भी design app में colour #FF5733 असल में 3 hex pairs हैं (red FF, green 57, blue 33), और आपके WiFi का MAC address 6 hex pairs का होता है।

Quiz

इनमें से कौन सा valid octal number नहीं है?

  1. 382
  2. 377
  3. 701
  4. 125
Show the answer

382

Octal base 8 है, तो इसके symbols सिर्फ 0 से 7 तक चलते हैं। 382 में जो 8 है, वो octal में exist ही नहीं करता, जैसे किसी हिंदी शब्द में Z अक्षर। ये "गलत digit ढूँढो" वाला सवाल exam का favourite है; कुछ भी करने से पहले हर digit को base के हिसाब से check कर लीजिए।

Think first

5 सेकंड का check

Hexadecimal में अकेले digit C की value क्या है? और hex number 1A की decimal value क्या होगी? दोनों reveal से पहले खुद निकालिए।

Show the answer

C = 12 (A=10, B=11, C=12)। और 1A₁₆ = 1·16 + 10·1 = 26।

अगर आपने C = 3 कहा (C को तीसरा letter गिनकर), तो ये classic गलती है: letters 10 से START होते हैं, इसलिए A=10 से ऊपर गिनिए, A=1 से नहीं।

Watch out

जहाँ marks कटते हैं

Binary को decimal की तरह पढ़ना: 101₂ का मतलब है 5, कभी भी "एक 100 एक" नहीं। Octal के अंदर digit 8 या 9 use कर देना, या ये भूल जाना कि hex के letters A=10 से शुरू होते हैं। और exam में हमेशा base को subscript में लिखिए (101₂, 377₈, FF₁₆): इसके बिना examiner समझ ही नहीं पाएगा कि आप किस system की बात कर रहे हैं, और ऐसे ambiguous answers में marks जाते हैं।

Theory

आगे क्या आने वाला है

अगला ही topic decimal और binary के बीच दोनों तरफ conversion सिखाएगा, और उसके बाद वाला binary में add और subtract करना, ठीक वही काम जो आपके block diagram का ALU दिन भर करता रहता है। आगे चलकर ASCII keyboard की हर key को एक number देगा, और वो numbers इन्हीं bits के रूप में travel करते हैं जिन्हें आप अभी पढ़ना सीखे। Base 2 पूरे course की ground floor है।

Summary

Key takeaways

  • Base = किसी system में कितने symbols हैं; positions base की powers लेकर चलती हैं।
  • Decimal base 10, binary base 2, octal base 8, hexadecimal base 16 (A=10 से F=15 तक)।
  • Computers binary use करते हैं क्योंकि transistors के पास exactly 2 reliable states होते हैं।
  • एक hex digit 4 binary bits समेट लेता है: 1111 1111₂ = FF₁₆ = 255।
  • Answers में base को हमेशा subscript में mark कीजिए।
  • याद रखने का तरीका: digit × base-power, और position दाईं तरफ से zero से गिनिए।

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

Number System: Decimal, Binary, Octal and Hexadecimal · Introduction to Computers · Gri-Learn