SlideShare ist ein Scribd-Unternehmen logo
1 von 13
Decimal to binary conversion:
Method of division by two
Decimal to binary conversion is based on the fact that a decimal number can be
represented as
d=an2^n+a(n-1)2^(n-1)+a(n-2)2^(n-2).........a(1)2^(1)+a(0)2^(0)
Eg 9=1*2^3 + 0*2^2 + 0*2^1 + 1*2^0
If we divide it by two we get the quotient as

q=d/2=a(n)2^(n-1)+a(n-1)2^(n-2)+a(n-2)2^(n-3).........+a(1)
and remainder r =a0(a0 is the least significant digit of the binary number.)
We again divide the quotient by two the

q/2=d/4=a(n)2^(n-2)+a(n-1)2^(n-3)+a(n-2)2^(n-4).........+a(2)
and the remainder =a1
Method of division by 2 continued



We continue this process until the quotient becomes zero.
Eg 19=d= 1*2^4 + 0*2^3 + 0*2^2 + 1*2^1 + 1*2^0
q=d/2= 1*2^3 + 0*2^2 + 0*2^1 + 1*2^0
r1=1
q/2=d/2*2=1*2^2 + 0*2^1 + 0*2^0
r2=1
q/2*2=d/2*2*2= 1*2^1 + 0*2^0
r3=0
q/2*2*2=d/2*2*2*2=1*2^0
r4=0
q/2*2*2*2=d/2*2*2*2*2=0
r5=1

Thus the binary equivalent of 19 is 10011.
Division by 2 algorithm



var
D:integer {D is the decimal integer that is to be converted to binary};
B:bitstring{B stores the binary equivalent of D};
Q,R:integer{intermediate variables used in conversion};
input D;
b:null;
if(D=0) then begin B:=0 goto 10 end;
while (D!=0)do
begin
Q:=D div 2 {D div 2 gives the quotient of D/2}
R:=D mod 2;
B=concatenate to left (R,B);
D:=Q
end;
10:Output B;
end{of algorithm}
Converting decimal fraction to binary




To convert a decimal fraction to binary we use repeated division on the
integral part and repeated multiplication on the decimal part. Suppose we
want to convert (11.625)10 binary . We find the binary equivalent of 11 by
repeated division and binary equivalent of 625 by repeated multiplication.
The process of repeated multiplication is explained below.
Step 1. Multiply the decimal part by 2. The whole number part of the result
becomes the first number to right of the decimal point .
.625*2=1.25
so the first number to the right is 1

step 2 . We take the decimal part of the result and again multiply it by two .
.25*2=.050
So the second number to the right is 0.
Converting decimal fraction to binary continued




step 3. We take the decimal part of the result and again multiply it by 2
.50*2= 1.00
So the third number to the right of the decimal point is 1.

Step.4 There is no need for step 4 as the fractional part has become
zero.

So our answer becomes 1011.101
Converting decimal fraction to binary :Algorithm



var
D:real {D is the decimal fraction to be converted to binary};
B:Bitstring {Binary equivalent of D};
P:real {P is a intermediate variable used during conversion};
INTP:Bit{integer part of 9 which can either be 0 or 1};
begin {of algorithm}
input D;
B:=0 .null {null is a null string};
if(D=0) then begin B:=0; goto 10 end;
while(D!=0) and length (B)<=9 do
{length (B) returns the length of B and we have limited it to 9}
begin
P:=D*2;
INTP:=Trunc(P){Trunc P returns the integer part of P};
Binary decimal conversion
Binary decimal conversion
Binary decimal conversion
Binary decimal conversion
Binary decimal conversion

Weitere ähnliche Inhalte

Was ist angesagt?

Number systems - binary, BCD, 2s comp
Number systems - binary, BCD, 2s compNumber systems - binary, BCD, 2s comp
Number systems - binary, BCD, 2s compmrlee2014
 
2s complement arithmetic
2s complement arithmetic2s complement arithmetic
2s complement arithmeticSanjay Saluth
 
Bc0052 – theory of computer science
Bc0052 – theory of computer scienceBc0052 – theory of computer science
Bc0052 – theory of computer sciencesmumbahelp
 
1’s and 2’s complements
1’s and 2’s complements1’s and 2’s complements
1’s and 2’s complementsarunachalamr16
 
Subtraction with Regrouping
Subtraction with RegroupingSubtraction with Regrouping
Subtraction with RegroupingJohdener14
 
1's and 2's complement
1's and 2's complement 1's and 2's complement
1's and 2's complement Shiraz Azeem
 
No factorization,no complex methods -Simplest method to solve quadratic equa...
No factorization,no complex methods -Simplest method to solve  quadratic equa...No factorization,no complex methods -Simplest method to solve  quadratic equa...
No factorization,no complex methods -Simplest method to solve quadratic equa...FabMarks
 
Square Roots without a Calculator - John Doe
Square Roots without a Calculator - John DoeSquare Roots without a Calculator - John Doe
Square Roots without a Calculator - John Doemrstafford
 
Matrix Chain Scheduling Algorithm
Matrix Chain Scheduling AlgorithmMatrix Chain Scheduling Algorithm
Matrix Chain Scheduling AlgorithmWen-Shih Chao
 
1sand2scomplement r004
1sand2scomplement  r0041sand2scomplement  r004
1sand2scomplement r004arunachalamr16
 
EC Binary Substraction using 1's Complement,2's Complement
EC Binary Substraction using 1's Complement,2's ComplementEC Binary Substraction using 1's Complement,2's Complement
EC Binary Substraction using 1's Complement,2's ComplementAmberSinghal1
 

Was ist angesagt? (19)

2's complement
2's complement2's complement
2's complement
 
Number systems - binary, BCD, 2s comp
Number systems - binary, BCD, 2s compNumber systems - binary, BCD, 2s comp
Number systems - binary, BCD, 2s comp
 
Chapter 7 rohith
Chapter 7 rohithChapter 7 rohith
Chapter 7 rohith
 
2s complement arithmetic
2s complement arithmetic2s complement arithmetic
2s complement arithmetic
 
Bc0052 – theory of computer science
Bc0052 – theory of computer scienceBc0052 – theory of computer science
Bc0052 – theory of computer science
 
1’s and 2’s complements
1’s and 2’s complements1’s and 2’s complements
1’s and 2’s complements
 
Induction q
Induction qInduction q
Induction q
 
Subtraction with Regrouping
Subtraction with RegroupingSubtraction with Regrouping
Subtraction with Regrouping
 
Two’s complement
Two’s complementTwo’s complement
Two’s complement
 
1's and 2's complement
1's and 2's complement 1's and 2's complement
1's and 2's complement
 
No factorization,no complex methods -Simplest method to solve quadratic equa...
No factorization,no complex methods -Simplest method to solve  quadratic equa...No factorization,no complex methods -Simplest method to solve  quadratic equa...
No factorization,no complex methods -Simplest method to solve quadratic equa...
 
Ncvps seq series
Ncvps seq seriesNcvps seq series
Ncvps seq series
 
Square Roots without a Calculator - John Doe
Square Roots without a Calculator - John DoeSquare Roots without a Calculator - John Doe
Square Roots without a Calculator - John Doe
 
Matrix Chain Scheduling Algorithm
Matrix Chain Scheduling AlgorithmMatrix Chain Scheduling Algorithm
Matrix Chain Scheduling Algorithm
 
Digital logic mohammed salim ch2
Digital logic mohammed salim ch2Digital logic mohammed salim ch2
Digital logic mohammed salim ch2
 
Number systems ppt
Number systems pptNumber systems ppt
Number systems ppt
 
1sand2scomplement r004
1sand2scomplement  r0041sand2scomplement  r004
1sand2scomplement r004
 
Ch03pp
Ch03ppCh03pp
Ch03pp
 
EC Binary Substraction using 1's Complement,2's Complement
EC Binary Substraction using 1's Complement,2's ComplementEC Binary Substraction using 1's Complement,2's Complement
EC Binary Substraction using 1's Complement,2's Complement
 

Ähnlich wie Binary decimal conversion

Switching circuits and logic design
Switching circuits and logic designSwitching circuits and logic design
Switching circuits and logic designgoutamkrsahoo
 
Module 1 number systems and code1
Module 1  number systems and code1Module 1  number systems and code1
Module 1 number systems and code1Deepak John
 
digital-electronics.pptx
digital-electronics.pptxdigital-electronics.pptx
digital-electronics.pptxsulekhasaxena2
 
Ee 202 chapter 1 number and code system
Ee 202 chapter 1 number and code system Ee 202 chapter 1 number and code system
Ee 202 chapter 1 number and code system CT Sabariah Salihin
 
T2311 - Ch 4_Part1.pptx
T2311 - Ch 4_Part1.pptxT2311 - Ch 4_Part1.pptx
T2311 - Ch 4_Part1.pptxGadaFarhan
 
chapter1digitalsystemsandbinarynumbers-151021072016-lva1-app6891.pptx
chapter1digitalsystemsandbinarynumbers-151021072016-lva1-app6891.pptxchapter1digitalsystemsandbinarynumbers-151021072016-lva1-app6891.pptx
chapter1digitalsystemsandbinarynumbers-151021072016-lva1-app6891.pptxSurendra Loya
 
Lecture 02 - Logic Design(Number Systems).pptx
Lecture 02 - Logic Design(Number Systems).pptxLecture 02 - Logic Design(Number Systems).pptx
Lecture 02 - Logic Design(Number Systems).pptxshwan it
 
mathematicalinductionanddivisibilityrules-160711105713.pdf
mathematicalinductionanddivisibilityrules-160711105713.pdfmathematicalinductionanddivisibilityrules-160711105713.pdf
mathematicalinductionanddivisibilityrules-160711105713.pdfBhanuCharan9
 
Mathematical induction and divisibility rules
Mathematical induction and divisibility rulesMathematical induction and divisibility rules
Mathematical induction and divisibility rulesDawood Faheem Abbasi
 
Data-Handling part 2.ppt
Data-Handling part 2.pptData-Handling part 2.ppt
Data-Handling part 2.pptAhmadHashlamon
 
tutorial5.ppt
tutorial5.ppttutorial5.ppt
tutorial5.pptjvjfvvoa
 
Karatsuba algorithm for fast mltiplication
Karatsuba algorithm for fast mltiplicationKaratsuba algorithm for fast mltiplication
Karatsuba algorithm for fast mltiplicationAtul Singh
 

Ähnlich wie Binary decimal conversion (20)

Switching circuits and logic design
Switching circuits and logic designSwitching circuits and logic design
Switching circuits and logic design
 
Chapter 1
Chapter   1Chapter   1
Chapter 1
 
CRYPTO 2.pptx
CRYPTO 2.pptxCRYPTO 2.pptx
CRYPTO 2.pptx
 
Module 1 number systems and code1
Module 1  number systems and code1Module 1  number systems and code1
Module 1 number systems and code1
 
digital-electronics.pptx
digital-electronics.pptxdigital-electronics.pptx
digital-electronics.pptx
 
Ee 202 chapter 1 number and code system
Ee 202 chapter 1 number and code system Ee 202 chapter 1 number and code system
Ee 202 chapter 1 number and code system
 
Number Systems Basic Concepts
Number Systems Basic ConceptsNumber Systems Basic Concepts
Number Systems Basic Concepts
 
L 2.10
L 2.10L 2.10
L 2.10
 
Floating point arithmetic
Floating point arithmeticFloating point arithmetic
Floating point arithmetic
 
Dld lecture module 02
Dld lecture module 02Dld lecture module 02
Dld lecture module 02
 
T2311 - Ch 4_Part1.pptx
T2311 - Ch 4_Part1.pptxT2311 - Ch 4_Part1.pptx
T2311 - Ch 4_Part1.pptx
 
PEA 305.pdf
PEA 305.pdfPEA 305.pdf
PEA 305.pdf
 
chapter1digitalsystemsandbinarynumbers-151021072016-lva1-app6891.pptx
chapter1digitalsystemsandbinarynumbers-151021072016-lva1-app6891.pptxchapter1digitalsystemsandbinarynumbers-151021072016-lva1-app6891.pptx
chapter1digitalsystemsandbinarynumbers-151021072016-lva1-app6891.pptx
 
Lecture 02 - Logic Design(Number Systems).pptx
Lecture 02 - Logic Design(Number Systems).pptxLecture 02 - Logic Design(Number Systems).pptx
Lecture 02 - Logic Design(Number Systems).pptx
 
coefficient variation
coefficient variationcoefficient variation
coefficient variation
 
mathematicalinductionanddivisibilityrules-160711105713.pdf
mathematicalinductionanddivisibilityrules-160711105713.pdfmathematicalinductionanddivisibilityrules-160711105713.pdf
mathematicalinductionanddivisibilityrules-160711105713.pdf
 
Mathematical induction and divisibility rules
Mathematical induction and divisibility rulesMathematical induction and divisibility rules
Mathematical induction and divisibility rules
 
Data-Handling part 2.ppt
Data-Handling part 2.pptData-Handling part 2.ppt
Data-Handling part 2.ppt
 
tutorial5.ppt
tutorial5.ppttutorial5.ppt
tutorial5.ppt
 
Karatsuba algorithm for fast mltiplication
Karatsuba algorithm for fast mltiplicationKaratsuba algorithm for fast mltiplication
Karatsuba algorithm for fast mltiplication
 

Kürzlich hochgeladen

Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...Orbitshub
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProduct Anonymous
 
Corporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxCorporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxRustici Software
 
CNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In PakistanCNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In Pakistandanishmna97
 
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Jeffrey Haguewood
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century educationjfdjdjcjdnsjd
 
Introduction to Multilingual Retrieval Augmented Generation (RAG)
Introduction to Multilingual Retrieval Augmented Generation (RAG)Introduction to Multilingual Retrieval Augmented Generation (RAG)
Introduction to Multilingual Retrieval Augmented Generation (RAG)Zilliz
 
Platformless Horizons for Digital Adaptability
Platformless Horizons for Digital AdaptabilityPlatformless Horizons for Digital Adaptability
Platformless Horizons for Digital AdaptabilityWSO2
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businesspanagenda
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FMESafe Software
 
DBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDropbox
 
Elevate Developer Efficiency & build GenAI Application with Amazon Q​
Elevate Developer Efficiency & build GenAI Application with Amazon Q​Elevate Developer Efficiency & build GenAI Application with Amazon Q​
Elevate Developer Efficiency & build GenAI Application with Amazon Q​Bhuvaneswari Subramani
 
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 AmsterdamDEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 AmsterdamUiPathCommunity
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobeapidays
 
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...Angeliki Cooney
 
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...apidays
 
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Victor Rentea
 

Kürzlich hochgeladen (20)

+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
 
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
Corporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxCorporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptx
 
CNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In PakistanCNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In Pakistan
 
Understanding the FAA Part 107 License ..
Understanding the FAA Part 107 License ..Understanding the FAA Part 107 License ..
Understanding the FAA Part 107 License ..
 
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
Introduction to Multilingual Retrieval Augmented Generation (RAG)
Introduction to Multilingual Retrieval Augmented Generation (RAG)Introduction to Multilingual Retrieval Augmented Generation (RAG)
Introduction to Multilingual Retrieval Augmented Generation (RAG)
 
Platformless Horizons for Digital Adaptability
Platformless Horizons for Digital AdaptabilityPlatformless Horizons for Digital Adaptability
Platformless Horizons for Digital Adaptability
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
DBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor Presentation
 
Elevate Developer Efficiency & build GenAI Application with Amazon Q​
Elevate Developer Efficiency & build GenAI Application with Amazon Q​Elevate Developer Efficiency & build GenAI Application with Amazon Q​
Elevate Developer Efficiency & build GenAI Application with Amazon Q​
 
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 AmsterdamDEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
 
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
 
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
 
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
 

Binary decimal conversion

  • 1.
  • 2.
  • 3. Decimal to binary conversion: Method of division by two Decimal to binary conversion is based on the fact that a decimal number can be represented as d=an2^n+a(n-1)2^(n-1)+a(n-2)2^(n-2).........a(1)2^(1)+a(0)2^(0) Eg 9=1*2^3 + 0*2^2 + 0*2^1 + 1*2^0 If we divide it by two we get the quotient as q=d/2=a(n)2^(n-1)+a(n-1)2^(n-2)+a(n-2)2^(n-3).........+a(1) and remainder r =a0(a0 is the least significant digit of the binary number.) We again divide the quotient by two the q/2=d/4=a(n)2^(n-2)+a(n-1)2^(n-3)+a(n-2)2^(n-4).........+a(2) and the remainder =a1
  • 4. Method of division by 2 continued We continue this process until the quotient becomes zero. Eg 19=d= 1*2^4 + 0*2^3 + 0*2^2 + 1*2^1 + 1*2^0 q=d/2= 1*2^3 + 0*2^2 + 0*2^1 + 1*2^0 r1=1 q/2=d/2*2=1*2^2 + 0*2^1 + 0*2^0 r2=1 q/2*2=d/2*2*2= 1*2^1 + 0*2^0 r3=0 q/2*2*2=d/2*2*2*2=1*2^0 r4=0 q/2*2*2*2=d/2*2*2*2*2=0 r5=1 Thus the binary equivalent of 19 is 10011.
  • 5. Division by 2 algorithm var D:integer {D is the decimal integer that is to be converted to binary}; B:bitstring{B stores the binary equivalent of D}; Q,R:integer{intermediate variables used in conversion}; input D; b:null; if(D=0) then begin B:=0 goto 10 end; while (D!=0)do begin Q:=D div 2 {D div 2 gives the quotient of D/2} R:=D mod 2; B=concatenate to left (R,B); D:=Q end; 10:Output B; end{of algorithm}
  • 6. Converting decimal fraction to binary To convert a decimal fraction to binary we use repeated division on the integral part and repeated multiplication on the decimal part. Suppose we want to convert (11.625)10 binary . We find the binary equivalent of 11 by repeated division and binary equivalent of 625 by repeated multiplication. The process of repeated multiplication is explained below. Step 1. Multiply the decimal part by 2. The whole number part of the result becomes the first number to right of the decimal point . .625*2=1.25 so the first number to the right is 1 step 2 . We take the decimal part of the result and again multiply it by two . .25*2=.050 So the second number to the right is 0.
  • 7. Converting decimal fraction to binary continued step 3. We take the decimal part of the result and again multiply it by 2 .50*2= 1.00 So the third number to the right of the decimal point is 1. Step.4 There is no need for step 4 as the fractional part has become zero. So our answer becomes 1011.101
  • 8. Converting decimal fraction to binary :Algorithm var D:real {D is the decimal fraction to be converted to binary}; B:Bitstring {Binary equivalent of D}; P:real {P is a intermediate variable used during conversion}; INTP:Bit{integer part of 9 which can either be 0 or 1}; begin {of algorithm} input D; B:=0 .null {null is a null string}; if(D=0) then begin B:=0; goto 10 end; while(D!=0) and length (B)<=9 do {length (B) returns the length of B and we have limited it to 9} begin P:=D*2; INTP:=Trunc(P){Trunc P returns the integer part of P};