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
| System | Base | Symbols | ક્યાં મળે છે |
|---|---|---|---|
| Decimal | 10 | 0 થી 9 | રોજિંદું જીવન, પૈસા |
| Binary | 2 | 0, 1 | Computer ની બધી internal વસ્તુ |
| Octal | 8 | 0 થી 7 | Unix file permissions, legacy |
| Hexadecimal | 16 | 0-9 અને A-F | Colour 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 નથી?
- 382
- 377
- 701
- 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 જમણી બાજુથી શૂન્યથી ગણવાની.