Conversion of Decimal to Binary and Binary to Decimal

Decimal ને binary માં convert કરવું હોય તો 2 વડે વારંવાર ભાગો અને remainder ને નીચેથી ઉપર વાંચો; binary ને decimal માં convert કરવું હોય તો દરેક bit ને એની power of 2 સાથે ગુણો અને બધું ઉમેરો.

10 min read · 10 cards · 2 checks

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


Theory

25 ને computer ની ભાષામાં લખો

Chirag shop ના whiteboard પર 25 લખે છે અને તમારા હાથમાં marker આપે છે: "આ રીતે તો માણસ લખે. મને બતાવ કે machine એને કઈ રીતે store કરે."

Machine ની અંદર તો બસ switch જ છે: on, off, on... એટલે 25 ને 1 અને 0 ની હાર બનાવવી પડે.

2 mechanical recipe છે, એક-એક direction માટે, અને આખા subject માં આ 2 વસ્તુ સૌથી પાક્કા marks આપે છે: ચોખ્ખી method, ભૂલી જવાય એવી કોઈ theory નહીં.

Follow along

Decimal → binary: નીચે ભાગો, ઉપર વાંચો

  1. Number ને 2 વડે ભાગો Quotient નીચે લખો, remainder (0 કે 1) એની બાજુમાં લખો.
  2. દરેક quotient ને ફરી 2 વડે ભાગતા રહો દરેક step માં remainder 0 કે 1 જ આવે. Quotient 0 ના થાય ત્યાં સુધી ચાલુ રાખો.
  3. Remainder ને નીચેથી ઉપર વાંચો છેલ્લો remainder એ સૌથી ડાબી બાજુનો bit. આ direction માં જ મોટાભાગના marks જાય છે.
  4. પાછું convert કરીને check કરો 30 second નો positional sum દરેક નાની-મોટી ભૂલ પકડી પાડે.

Theory

ઉકેલી બતાવીએ: 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, અને એ જ તો છેલ્લો (સૌથી જમણી બાજુનો) bit થાય. પછીના દરેક division મોટા-મોટા chunk પર કામ કરે છે, એટલે એ more significant bits આપે.

Theory

Binary → decimal: power ની સીડી

ઊંધી direction એ તો છેલ્લા topic નો positional rule જ છે. Bits ની ઉપર 2 ની power લખો, જમણેથી ડાબે: 1, 2, 4, 8, 16, 32, 64, 128...

bits: 1 1 0 0 1

power: 16 8 4 2 1

જ્યાં 1 છે એની નીચેની power ઉમેરો, 0 ને છોડી દો:

16 + 8 + 1 = 25 ✓

એ જ number પાછો આવ્યો, અને આ જ તો steps માં કહેલી verification ની ટેવ છે: exam માં દરેક conversion નો answer આ round trip કરી શકવો જોઈએ.

Think first

હવે તમારો વારો: 13

કાગળ પર division method થી 13 ને binary માં convert કરો. પછી તમારો answer power ની સીડી થી પાછો convert કરીને check કરો. 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 ✓

જો તમને 1011 આવ્યું હોય, તો તમે remainder ને ઉપરથી નીચે વાંચ્યા, અને આ જ conversion માં સૌથી common ભૂલ છે. યાદ રાખો: નીચે ભાગો, ઉપર વાંચો.

Quiz

1010₂ ને decimal માં કેટલા થાય?

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

10

Bits ની નીચે power લખો: 8, 4, 2, 1. 1 એ 8 અને 2 પર બેઠા છે, એટલે 8 + 2 = 10. જો તમે 5 પસંદ કર્યું હોય તો bits ને ઊંધા વાંચ્યા (0101), અને 101 નો મતલબ કે તમે binary ને જાણે એ પહેલેથી decimal જ હોય એમ treat કર્યું. દર વખતે bits ઉપર power ની સીડી ગોઠવો.

Watch out

Marks ખાઈ જતી 2 ભૂલો

Remainder ને ઉપરથી નીચે વાંચવા: આ તમને એકદમ ઊંધો, mirror જેવો ખોટો answer આપશે; method તો છે નીચે ભાગો, ઉપર વાંચો. સીડી પર લપસી પડવું: 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 લખો, નીચેથી ઉપર વાંચેલા remainder ને box કરો, અને પછી પાછું convert કરીને એક verification line ઉમેરો. "convert bits to decimal" માટે: bits ની ઉપર power ની સીડી લખો, 1 ની નીચેની power ઉમેરો. આ બંને format બરાબર એ જ છે જેને examiner આખા method ના marks આપે છે.

Theory

આ તમને વારંવાર ક્યાં કામ લાગશે

આવતા topic માં આ જ bit-strings ને add અને subtract કરીશું, જે ALU નું રોજનું કામ છે. Address-bus નો 2ⁿ rule, ASCII codes, networking માં subnet masks (Sem 5), એટલે સુધી કે colour #FF5733: conversion reflex થઈ જાય એટલે આ બધું વાંચી શકાય એવું બની જાય. 0 થી 31 જૂના દોસ્ત જેવા લાગે ત્યાં સુધી practice કરો.

Summary

Key takeaways

  • Decimal → binary: 2 વડે વારંવાર ભાગો, remainder ને નીચેથી ઉપર વાંચો.
  • Binary → decimal: power ની સીડી (1,2,4,8,16,...), 1 ની નીચેની power ઉમેરો.
  • હંમેશા ઊંધા conversion થી verify કરો, ફક્ત 30 second લાગે છે.
  • પહેલો remainder એ સૌથી જમણી બાજુનો bit (odd/even test).
  • Division table બતાવો: arithmetic ની ભૂલ થાય તોય method ના marks બચે.
  • યાદ રાખવાની trick: નીચે ભાગો, ઉપર વાંચો.

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