Aithmetic Conversions

© All Rights Reserved

0 views

Aithmetic Conversions

© All Rights Reserved

- The Swift Programming Language
- Digital Principles and Logic Design
- Curso Assembler PIC
- Unplugged 01 Binary Numbers
- Compiled Programs
- An Analysis of the Information Spreading Delay in Heterogeneous Mobility DTNs
- 1.1.2 Hexadecimal
- Number System
- Unit 2 Revision Guide
- 9 Section 1.1 Notes
- Compact PLC OMRON.pdf
- l2s-u18 a1-cp
- A Aaaaaaaaaaaaaaaaaaaaaaaa
- l2s-u18 a1-cp
- Binary Numbers
- C# Extra References
- DS - 8-10
- Epc Assignment
- Practice Paper A1 MS
- Cheat Sheet

You are on page 1of 5

HTM

One of the basic skills a programmer needs is the ability to convert numbers between decimal, hexadecimal, and binary. This article will demonstrate the

conversions between each of these bases.

Decimal to Hexadecimal

2) Divide X by 16, saving the quotient as Q, and the remainder (in hexadecimal) as Rk .

4) Assume steps 1-3 were repeated n times. Arrange the remainders as a string of digits - RnRn-1Rn-2…R3R2R1 .

Here is an example where we number and describe each iteration of the algorithm:

1) Let X = 954 and let k = 1. Dividing by 16 we have Q = 59 and R1 = A (10 = A in hexadecimal). Since Q is not zero, we let X = 59 and go back to start the

second iteration.

2) Dividing X = 59 by 16, we have Q = 3 and R2 = B since 11 = B in hexadecimal. Since Q is not zero, we let X = 3 and start the third iteration.

3) Dividing X = 3 by 16, we have Q = 0 and R3 = 3. Since Q = 0, the loop terminates and the algorithm is completed by arranging the remainders as “3BA”.

Here is another example using long division. In this example we convert 2623 in decimal to A3F in hexadecimal. The computations move from right to left.

1 of 5 5/12/2018, 7:30 PM

http://csc.columbusstate.edu/woolbright/CONV.HTM

Hexadecimal to Decimal

Consider the problem of converting the hexadecimal number A3B7 to decimal. Each hexadecimal digit in the representation represents a number of

occurrences of a power of 16. We can change each hexadecimal digit to its decimal equivalent and multiply by the corresponding power of 16. Totaling the

components produces the decimal representation of the original hexadecimal number.

3 = 3 x 162 = 3 x 256 = 768

B = 11 x 161 = 11 x 16 = 176

7 0

= 7 x 16 = 7 x 1 = 7

Total = 41911

F= 15 x 162 = 15 x 256 = 3840

B = 11 x 161 = 11 x 16 = 176

0

9= 7 x 16 = 9 x 1 = 9

Total = 16313

Decimal to Binary

When a number is expressed in binary, each 1 in the expression represents a power of 2 ( 1, 2, 4, 8, …). Perhaps the faster way to convert from decimal to

binary involves removing successive powers of two (starting with the largest and proceeding to the smallest) from the decimal number. Each time we are able to

remove a power of 2, we record a 1 in the binary representation. Each time we are unable to remove a power of 2, we record a 0 in the binary representation.

2 of 5 5/12/2018, 7:30 PM

http://csc.columbusstate.edu/woolbright/CONV.HTM

The operation proceeds from left to right. Consider the problem of converting the decimal integer 115 to binary. The largest power of 2 which can be removed

from 115 is 26 = 64. Removing 64 leaves 115 - 64 = 51. We record the removal of 64 as a 1 in the leftmost digit of the binary representation (1…). Next we

remove 32 from 51. This leaves 51 - 32 = 19, and we record another 1 in the binary representation ( 11…). Continuing, we remove 16 from 19 leaving 3, and we

record another 1 ( 111…). The next two powers of 2 are 8 and 4. These cannot be removed from 3 and so we record 0 in the next two positions (11100…).

Next we remove 2 from 3 and then 1 from 1, recording 1 in the last two positions (1110011).

Here is an illustration where the decimal integer 82 is converted to the binary representation “1010010”. The computation proceeds from left to right with the

successive removal of powers of 2. Notice that when a power of 2 is successfully removed it causes a “1” to occur in the binary representation. When we are

unsuccessful, a “0” appears.

Binary to Decimal

In the representation of a binary integer, each 1 indicates the occurrence of the corresponding power of 2. To convert to decimal, we simply compute the total

of the powers of 2 which correspond to a 1. Consider the following example in which we convert 1101110 to a decimal representation.

1 = 1 x 26 = 64

1 = 1 x 25 = 32

0 = 0 x 24 = 0

1 = 1 x 23 = 8

1 = 1 x 22 = 4

1 = 1 x 21 = 2

0 = 0 x 20 = 0

Total = 110

1 = 1 x 25 = 32

0 = 0 x 24 = 0

3 of 5 5/12/2018, 7:30 PM

http://csc.columbusstate.edu/woolbright/CONV.HTM

0 = 0 x 23 = 0

1 = 1 x 22 = 4

1 = 1 x 21 = 2

1 = 1 x 20 = 1

Total = 39

Hexadecimal to Binary

Base 16 and base 2 are “compatible” bases since 16 is a power of 2. This makes the conversion from hexadecimal to binary quite easy: Replace each

hexadecimal digit with its four-bit binary representation. Here is an example in which the hexadecimal number AB9F3C is converted to

101010111001111100111100.

Binary to Hexadecimal

Converting from binary to hexadecimal involves replacing each consecutive block of four bits in the binary representation (moving from right to left within the

representation) with its hexadecimal equivalent. You may need to add 0’s on the left of the binary representation in order that the number of 1’s and 0’s is a

multiple of 4. Consider the following conversion.

4 of 5 5/12/2018, 7:30 PM

http://csc.columbusstate.edu/woolbright/CONV.HTM

Each block of four bits beginning with 1010 is replaced with one hexadecimal digit. The leftmost 2 digits 11 are treated as 0011 and converted to “3”.

5 of 5 5/12/2018, 7:30 PM

- The Swift Programming LanguageUploaded byHugo Ricardo Ariza Arriaga
- Digital Principles and Logic DesignUploaded byInsane Clown Prince
- Curso Assembler PICUploaded byJoud da Sanfona
- Unplugged 01 Binary NumbersUploaded byStephenson
- Compiled ProgramsUploaded byaksagar22
- An Analysis of the Information Spreading Delay in Heterogeneous Mobility DTNsUploaded bymiladydesummer
- 1.1.2 HexadecimalUploaded byAhmed Samad
- Number SystemUploaded byRenie
- Unit 2 Revision GuideUploaded bybhagirath1
- 9 Section 1.1 NotesUploaded byMsHardiman
- Compact PLC OMRON.pdfUploaded bymangyan
- l2s-u18 a1-cpUploaded byapi-272358643
- A AaaaaaaaaaaaaaaaaaaaaaaaUploaded byflupt
- l2s-u18 a1-cpUploaded byapi-272358643
- Binary NumbersUploaded byMj Jm AH
- C# Extra ReferencesUploaded byRuchi Modi
- DS - 8-10Uploaded byapi-3707411
- Epc AssignmentUploaded byapi-3825919
- Practice Paper A1 MSUploaded byshah143
- Cheat SheetUploaded byMarullz
- 5 markUploaded byVibhour Upadhyay
- CST PPTUploaded byMonique
- code2Uploaded byzobi87
- Fundamentals of Mathematics Lecture 1Uploaded byKalindu Liyanage
- asubmit to leo at1 s00112512Uploaded byapi-254787407
- interviews assessment analysisUploaded byapi-242073541
- RPT MT THN 6Uploaded byjju4800
- discrete optimization lecture 1Uploaded byVictor Mariano Leite
- Binary AranaUploaded byEisuuki Terada
- Tutorial 1Uploaded byShin Yoo

- Foundations of MathematicsUploaded byAhmad Alhour
- CPU SchedulingUploaded byAnonymous s3TzBvwS1
- Testrestapi Sample PreviewUploaded byMarwa De Hatoum
- Greedy MethodUploaded byAnonymous s3TzBvwS1
- SL-500-EE5Uploaded byutham143
- ForensicsUploaded byzeeshan17
- All the Mathematics You MissedUploaded byfcsardinha
- Advanced Encryption Advanced EncryptionUploaded byAnonymous s3TzBvwS1
- Basic Concepts in Computer Hardware and SoftwareUploaded byJugal Kishore
- 501 Geometry Questions.pdfUploaded byAnonymous s3TzBvwS1
- Aritificial Intelligence Cheat Sheet Cheat SheetUploaded byAnonymous s3TzBvwS1
- Exercise 3Uploaded byAnonymous s3TzBvwS1
- Exercise 2Uploaded byAnonymous s3TzBvwS1
- Exercise 4Uploaded byAnonymous s3TzBvwS1
- Chapter 1Uploaded byAnonymous s3TzBvwS1
- chapter1.pdfUploaded byAnonymous s3TzBvwS1
- L12Uploaded byAnonymous s3TzBvwS1
- L02_StackUploaded byAnonymous s3TzBvwS1
- Live MS.pdfUploaded byAnonymous s3TzBvwS1
- 50 Math, Logic and Word Puzzles - Volume 1[EPUB][GLODLS]Uploaded bymanikanta
- 06.1 Collision Resistance IntroductionUploaded byAnonymous s3TzBvwS1
- etting up the Forensic Laboratory - Ch3.pdfUploaded byAnonymous s3TzBvwS1
- Mastering Entity FrameworkUploaded byAnonymous s3TzBvwS1
- C#AsyncPM TutorialUploaded byAnonymous s3TzBvwS1
- Test Case TemplateUploaded byArunesh Kumar Singh
- Advanced Stored ProceduresUploaded byOleksiy Kovyrin
- Sans Sec 660.4 - Exploiting Linux for Penetration TestersUploaded byAnonymous s3TzBvwS1
- Tor_Forensics_On_Windows_OS_Mattia_Epifani.pdfUploaded byAnonymous s3TzBvwS1
- MTA_SSG_NetFund_individual_without_cropUploaded byTorque Muliango

- T1 Pri WB Math P5.pdfUploaded byteerapong onogk
- Lampiran Perhitungan Kimtik Acara 4.docxUploaded byRike CA
- 4A Singapore Math 4a- TextbookUploaded bybrcrao
- Hp 300s ManualUploaded byDavid Wang
- rpt mat year 6Uploaded byKayalvile Vijaya Kumar
- 2018 - 2019 overall scope and sequence -mathUploaded byapi-338504614
- Knurling Turn Diameters Quick ReferenceUploaded byAnonymous RnWRfZQs
- maths program proforma yr 5 t2Uploaded byapi-237136245
- Booths Multiplication Algorithm 1204288806900951 3Uploaded byOnesimo Ramos Magallón
- Math 7 or math 1 summative testUploaded byCris Capilayan
- Chapter 1 Number Calculations Notes Form 2 2013Uploaded byWanie Shuib
- Unit 1Uploaded byganjookomal
- vedic mathsUploaded bycoolviv24
- V0_Sistem Bilangan_hbh [Compatibility Mode]Uploaded byrinaldi
- 002044Uploaded byAndrea Bates
- Onlinetest360.Com Quantitative aptitude pdfUploaded byRam Babu
- fx-5800P_ENUploaded byoscamora
- Sharp Writeview EL-W535 ManualUploaded byJkPhoenix
- M1.Mathematics rUploaded bysubroto
- Grade 7 Number SenseUploaded bymarkburke1
- Quantitative Aptitude workbookUploaded byNaieem
- printable flashcard on rational irrational numbers free flash cardsUploaded byapi-260036820
- Module - MATHUploaded byAniel John Santarin
- TALAAN NG ISPESIPIKASYON 3.xlsxUploaded byAngelica Legaspi
- Konversi Geografis Dan UTM (Formula Redfearn)Uploaded bySofyan Nemo
- Glencoe Algebra, chapter 2Uploaded byozbydesign
- Addition and Subtraction of Binary Numbers AkashUploaded byAkash
- Connected Mathematics 2 - Accentuate the Negative--Integers and Rational NumbersUploaded byIulia Rosu
- PIA B_Basic_Module 1.1 (MATHS) FinalUploaded byAhsan Malik
- h Se Handbook SubsetUploaded bysofiavictor