Number System: Decimal, Binary, Octal and Hexadecimal

Number system એની base થી define થાય છે (એટલે એની પાસે કેટલા symbols છે); computer binary (base 2) વાપરે છે કારણ કે circuit ને ખાલી ON અને OFF જ ખબર છે, અને octal તથા hex એ compact shorthand તરીકે વપરાય છે.

10 min read · 10 cards · 2 checks

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


Theory

Chirag ના T-shirt પરની મજાક

Chirag ના Friday ના T-shirt પર લખ્યું છે: "There are 10 kinds of people: those who understand binary and those who don't."

Customer મરક મરક હસે છે પણ સાચી વાત સમજાતી નથી. તમને 4 જ મિનિટમાં સમજાઈ જશે.

આ મજાક પાછળનું ખરું puzzle આ છે: "10" આ symbols હંમેશા 10 નથી થતા. કોઈ પણ numeral નો અર્થ એ કયા system માં લખ્યો છે એના પર આધાર રાખે છે, અને computer તમારા કરતાં જુદું system વાપરે છે.

Theory

Circuit 2 માં જ કેમ ગણે છે

દુકાનમાં કોઈ પણ switch જુઓ: ON અથવા OFF. અડધું ON એવું કંઈ હોતું નથી. Computer એ લાખો microscopic switch (transistor) નું બનેલું છે, એટલે એની કુદરતી ભાષામાં ખાલી 2 જ અક્ષર છે: current વહે એ 1, અને current ના વહે એ 0. Circuit ને 10 voltage level ભરોસાપાત્ર રીતે સાચવવાનું કહો તો error આવવાના જ; 2 state તો સ્પષ્ટ અને સસ્તા. Binary હોવાનું આખું કારણ બસ આટલું જ છે.

Theory

દરેક system નીચે એક જ નિયમ

આ બધા system positional છે: એટલે digit ની value = digit × (base ને એની position જેટલી power ચઢાવીએ), અને position જમણી બાજુથી 0 થી ગણવાની.

Decimal માં તમે આ ધ્યાન આપ્યા વગર જ કરો છો:

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

એ જ નિયમ, 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". હવે તમે પહેલા વાળા type માં આવી ગયા.

At a glance

Exam માં આવતા 4 system

SystemBaseSymbolsક્યાં મળે છે
Decimal100 થી 9રોજિંદું જીવન, પૈસા
Binary20, 1Computer ની બધી internal વસ્તુ
Octal80 થી 7Unix file permissions, legacy
Hexadecimal160-9 અને A-FColour codes, MAC addresses

Theory

Hex: binary નું shorthand

Base 16 ને સોળ symbols જોઈએ, એટલે 9 પછી એ letters ઉધાર લે છે: A=10, B=11, C=12, D=13, E=14, F=15.

આટલી માથાકૂટ શા માટે? કારણ કે એક hex digit = બરાબર 4 binary bits, એટલે લાંબી લાંબી bit-string નાની થઈ જાય:

1111 1111₂ = FF₁₆ = 255

Hex તો તમે આખી જિંદગી જોયું જ છે: કોઈ પણ design app માં colour #FF5733 એ 3 hex pair છે (red FF, green 57, blue 33), અને તમારા WiFi નું MAC address એ 6 hex pair નું બનેલું છે.

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 માં અસ્તિત્વમાં જ નથી, જેમ કોઈ હિન્દી શબ્દમાં Z ના હોય. આ "ખોટો digit શોધો" ટાઈપનો પ્રશ્ન exam નો favourite છે; બીજું કંઈ કરતાં પહેલાં દરેક digit ને base સામે ચકાસી લેવો.

Think first

5 સેકન્ડનું check

Hexadecimal માં એકલા digit C ની value કેટલી? અને hex number 1A ની decimal value કેટલી થાય? જવાબ જોતાં પહેલાં બંને ગણી કાઢો.

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

માર્ક ક્યાં ગુમાવાય છે

Binary ને decimal ની જેમ મોટેથી વાંચવું: 101₂ એ 5 છે, ક્યારેય "એકસો એક" નહીં. Octal ની અંદર digit 8 કે 9 વાપરવું, અથવા hex ના letters A=10 થી શરૂ થાય છે એ ભૂલી જવું. અને exam માં base હંમેશા subscript તરીકે લખવો (101₂, 377₈, FF₁₆): એના વગર examiner ને ખબર જ ના પડે કે તમે કયું system કહો છો, અને ગૂંચવણ ભરેલા answer માં માર્ક કપાય.

Theory

હવે આગળ ક્યાં જવાનું

તરત પછીના topic માં decimal અને binary વચ્ચે બંને બાજુ conversion આવે છે, અને એની પછીના topic માં binary માં addition અને subtraction, બરાબર એ જ કામ જે તમારા block diagram નું ALU આખો દિવસ કરે છે. પછી ASCII keyboard ની દરેક key ને એક number આપે છે, અને એ numbers પેલા bits તરીકે જ મુસાફરી કરે છે જે તમે હમણાં વાંચતાં શીખ્યા. Base 2 એ આખા course નો પાયો છે.

Summary

Key takeaways

  • Base = system પાસે કેટલા symbols છે એ; positions base ની power લઈને આવે છે.
  • Decimal base 10, binary base 2, octal base 8, hexadecimal base 16 (A=10 થી F=15).
  • Computer binary વાપરે છે કારણ કે transistor પાસે બરાબર 2 ભરોસાપાત્ર state હોય છે.
  • એક hex digit 4 binary bits સમાવે છે: 1111 1111₂ = FF₁₆ = 255.
  • Answer માં base હંમેશા subscript તરીકે લખવો.
  • યાદ રાખવાની ટ્રીક: digit × base-power, position જમણી બાજુથી શૂન્યથી ગણવાની.

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