SlideShare une entreprise Scribd logo
1  sur  19
Binary Numbers
 Strings of binary digits (“bits”)
 One bit can store a number from 0 to 1
 n bits can store numbers from 0 to 2n

1
Binary – Powers of 2
 Positional representation
 Each digit represents a power of 2
So 101 binary is
1 • 22 + 0 • 21 + 1 • 20
or
1•4 + 0•2 + 1•1=5

2
Converting Binary to Decimal
 Easy, just multiply digit by power of 2
 Just like a decimal number is represented
 Example follows

3
Binary

Decimal Example

7

6

5

4

3

2

1

0

27

26

25

24

23

22

21

20

128

64

32

16

8

4

2

1

What is 10011100 in decimal?
1

0

0

1

1

1

0

0

128 + 0 + 0 + 16 + 8 + 4 + 0 + 0 = 156
4
Decimal to Binary
 A little more work than binary to decimal
 Some examples
 3 = 2 + 1 = 11 (that‟s 1•21 + 1•20)
 5 = 4 + 1 = 101 (that‟s 1•22 + 0•21 + 1•20)

5
Algorithm – Decimal to Binary
 Find largest power-of-two smaller than decimal

number
 Make the appropriate binary digit a „1‟
 Subtract the power of 2 from decimal
 Do the same thing again

6
Decimal

Binary Example

 Convert 28 decimal to binary

32 is too large, so use 16
Binary
10000
Decimal
Next is 8
Binary
11000
Decimal
Next is 4
Binary
11100
Decimal

28 – 16 = 12
12 – 8 = 4
4–4=0

7

6

5

4

3

2

1

0

27

26

25

24

23

22

21

20

128

64

32

16

8

4

2

1
7
Hexadecimal
 Strings of 0s and 1s too hard to write
 Use base-16 or hexadecimal – 4 bits

Dec

Bin

Hex

Dec

Bin

Hex

0

0000

0

8

1000

8

1

0001

1

9

1001

9

2

0010

2

10

1010

?

3

0011

3

11

1011

?

4

0100

4

12

1100

?

5

0101

5

13

1101

?

6

0110

6

14

1110

?

7

0111

7

15

1111

?
8
Hexadecimal
 Letters to represent 10-15

Dec

Bin

Hex

Dec

Bin

Hex

0

0000

0

8

1000

8

1

0001

1

9

1001

9

2

0010

2

10

1010

a

3

0011

3

11

1011

b

4

0100

4

12

1100

c

5

0101

5

13

1101

d

6

0110

6

14

1110

e

•Power of 2

7

0111

7

15

1111

f

•Size of byte

Why use
base 16?

9
Hex to Binary
Bin

Hex

0000

0

0001

1

0010

2

 Convention – write 0x before number

0011

3

 Hex to Binary – just convert digits

0100

4

0101

5

0110

6

0111

7

1000

8

1001

9

1010

a

1011

b

1100

c

1101

d

1110

e

1111

f

0x2ac
0010

1010 1100

0x2ac = 001010101100

No magic – remember hex digit = 4 bits

10
Binary to Hex

Bin
0000

0011
0100
0101

3

7

b

101001101111011 = 0x537b

5

0110

1011

4
6

0111

7

1000

8
9
a

1011

b

1100

c

1101

5

0111

3

1010

0011

2

1001

0101

1

0010

101001101111011

0

0001

 Just convert groups of 4 bits

Hex

d

1110

e

1111

f

11
Hex to Decimal

Dec

Hex

0

0

 Just multiply each hex digit by decimal value,

1

1

2

2

3

3

4

4

5

5

6

6

7

7

8

8

9

9

10

a

11

b

12

c

13

d

14

e

15

f

and add the results.

0x2ac
2 • 256


+ 10 • 16 + 12 • 1 = 684






163

162

161

160

4096

256

16

1

12
Decimal to Hex
1.

2.
3.
4.

Analogous to decimal
binary.
Find largest power-of-16 smaller than decimal
number
Divide by power-of-16. The integer result is hex
digit.
The remainder is new decimal number.
Do the same thing again

13
Decimal to Hex

Dec

Hex

0

0

1

1

2

2

3

3

4

4

5

5

6

6

7

7

8

8

9

9

10

a

11

b

12

c

13

d

160

14

e

1

15

f

684

0x2__

684/256 = 2
684%256 = 172

0x2a_
172%16 = 12 = c 0x2ac

172/16 = 10 = a

163
4096


162
256


161
16



14
Octal
 Octal is base 8
 Similar to hexadecimal
 Conversions

 Less convenient for use with 8-bit bytes

15
Arithmetic -- addition
 Binary similar to decimal arithmetic

1

No carries

0

1

1

0

0

0

1

1

0

0

1

0

1

1

0

+ 1

0

0

0

1

+ 1

0

1

1

1

1

1

1

0

1

1

1

1

0

Carries

1

0

1+1 is 2 (or 102), which results in a carry
16
Arithmetic -- subtraction

0

1
-

0

1

1

1

0

0

1

0

0

0

1

0

0

-

1

1

0

1

1

1

0

1

0

0

1

1

0

0

0

1

No borrows

1

0

1

1

Borrows

0 - 1 results in a borrow
17
Arithmetic -- multiplication

1

0

1

1

1

0

1

1

0

1

1

0

0

0

0

1

0

1

1

1

1

0

1

X

1

Successive additions of
multiplicand or zero,
multiplied by 2 (102).
Note that multiplication
by 102 just shifts bits
left.

1

18
Hexadecimal Arithmetic
 Similar
 If you‟re doing by hand, easiest to convert each set

of digits to decimal and back

19

Contenu connexe

Tendances

01.number systems
01.number systems01.number systems
01.number systems
rasha3
 
Number system
Number systemNumber system
Number system
kashee99
 
Decimal to binary number
Decimal to binary numberDecimal to binary number
Decimal to binary number
guestd8696a
 
Number system
Number systemNumber system
Number system
aviban
 

Tendances (18)

Cit 1101 lec 02
Cit 1101 lec 02Cit 1101 lec 02
Cit 1101 lec 02
 
01.number systems
01.number systems01.number systems
01.number systems
 
Number system
Number systemNumber system
Number system
 
Slide03 Number System and Operations Part 1
Slide03 Number System and Operations Part 1Slide03 Number System and Operations Part 1
Slide03 Number System and Operations Part 1
 
Decimal to binary number
Decimal to binary numberDecimal to binary number
Decimal to binary number
 
W 9 numbering system
W 9 numbering systemW 9 numbering system
W 9 numbering system
 
Number system computer fundamental
 Number  system computer fundamental  Number  system computer fundamental
Number system computer fundamental
 
01.Number Systems
01.Number Systems01.Number Systems
01.Number Systems
 
Digital Electronics- Number systems & codes
Digital Electronics- Number systems & codes Digital Electronics- Number systems & codes
Digital Electronics- Number systems & codes
 
Introducing to number system
Introducing to number systemIntroducing to number system
Introducing to number system
 
Number system
Number systemNumber system
Number system
 
Number+system (1)
Number+system (1)Number+system (1)
Number+system (1)
 
Representation Of Numbers and Characters
Representation Of Numbers and CharactersRepresentation Of Numbers and Characters
Representation Of Numbers and Characters
 
Number System
Number SystemNumber System
Number System
 
01.number systems
01.number systems01.number systems
01.number systems
 
Number systems tutorial
Number systems tutorialNumber systems tutorial
Number systems tutorial
 
Number system utm notes
Number system utm notesNumber system utm notes
Number system utm notes
 
Binary number systems
Binary number systemsBinary number systems
Binary number systems
 

Similaire à 01 intro

Similaire à 01 intro (20)

number system
number systemnumber system
number system
 
02 number systems
02 number systems02 number systems
02 number systems
 
Digital Logic Design.pptx
Digital Logic Design.pptxDigital Logic Design.pptx
Digital Logic Design.pptx
 
Number system by ammar nawab
Number system by ammar nawabNumber system by ammar nawab
Number system by ammar nawab
 
Number system
Number systemNumber system
Number system
 
Number System.pptx
Number System.pptxNumber System.pptx
Number System.pptx
 
Number system in Digital Electronics
Number system in Digital ElectronicsNumber system in Digital Electronics
Number system in Digital Electronics
 
Chapter02.pdf
Chapter02.pdfChapter02.pdf
Chapter02.pdf
 
uyuyuy.pdf
uyuyuy.pdfuyuyuy.pdf
uyuyuy.pdf
 
Number System and Conversions.pptx
Number System and Conversions.pptxNumber System and Conversions.pptx
Number System and Conversions.pptx
 
numbersystem-171028183820.pptx
numbersystem-171028183820.pptxnumbersystem-171028183820.pptx
numbersystem-171028183820.pptx
 
08 Numeral systems
08 Numeral systems08 Numeral systems
08 Numeral systems
 
Chapter1b
Chapter1bChapter1b
Chapter1b
 
Pertemuan 2 - Sistem Bilangan
Pertemuan 2 - Sistem BilanganPertemuan 2 - Sistem Bilangan
Pertemuan 2 - Sistem Bilangan
 
Number Systems
Number SystemsNumber Systems
Number Systems
 
Number Systems
Number SystemsNumber Systems
Number Systems
 
005618132.pdf
005618132.pdf005618132.pdf
005618132.pdf
 
Number Systems - AK.pptx
Number Systems - AK.pptxNumber Systems - AK.pptx
Number Systems - AK.pptx
 
Digital Electronics – Unit I.pdf
Digital Electronics – Unit I.pdfDigital Electronics – Unit I.pdf
Digital Electronics – Unit I.pdf
 
Number system
Number systemNumber system
Number system
 

Dernier

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
Safe Software
 
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
panagenda
 

Dernier (20)

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
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
Manulife - Insurer Innovation Award 2024
Manulife - Insurer Innovation Award 2024Manulife - Insurer Innovation Award 2024
Manulife - Insurer Innovation Award 2024
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
 
Top 5 Benefits OF Using Muvi Live Paywall For Live Streams
Top 5 Benefits OF Using Muvi Live Paywall For Live StreamsTop 5 Benefits OF Using Muvi Live Paywall For Live Streams
Top 5 Benefits OF Using Muvi Live Paywall For Live Streams
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?
 
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
 

01 intro