SlideShare a Scribd company logo
1 of 28
Number Systems
and
Number Representation
1
The Decimal Number System
Name
• “decem” (Latin) => ten
Characteristics
• Ten symbols
• 0 1 2 3 4 5 6 7 8 9
• Positional
• 2945 ≠ 2495
• 2945 = (2*103) + (9*102) + (4*101) + (5*100)
(Most) people use the decimal number system
Why?
2
The Binary Number System
Name
• “binarius” (Latin) => two
Characteristics
• Two symbols
• 0 1
• Positional
• 1010B ≠ 1100B
Most (digital) computers use the binary number system
Why?
Terminology
• Bit: a binary digit
• Byte: (typically) 8 bits
3
Decimal-Binary Equivalence
4
Decimal Binary Decimal Binary
0 0 16 10000
1 1 17 10001
2 10 18 10010
3 11 19 10011
4 100 20 10100
5 101 21 10101
6 110 22 10110
7 111 23 10111
8 1000 24 11000
9 1001 25 11001
10 1010 26 11010
11 1011 27 11011
12 1100 28 11100
13 1101 29 11101
14 1110 30 11110
15 1111 31 11111
... ...
Decimal-Binary Conversion
5
Binary to decimal: expand using positional notation
(1*25)+(0*24)+(0*23)+(1*22)+
100101B =
= 32 + 0 + 0 + 4 +
(0*21)+(1*20
) 0 +
1
= 37
Decimal-Binary Conversion
6
Decimal to binary: do the reverse
• Determine largest power of 2 ≤ number; write template
• Fill in template
37 = (?*25)+(?*24)+(?*23)+(?*22)+(?*21)+(?*20)
37 = (1*25)+(0*24)+(0*23)+(1*22)+(0*21)+(1*20)
-32
5
-4
1 100101B
-1
0
Decimal-Binary Conversion
Decimal to binary shortcut
• Repeatedly divide by 2, consider remainder
37 / 2 = 18 R 1
18 / 2 = 9 R 0
9 / 2 = 4 R 1
4 / 2 = 2 R 0
2 / 2 = 1 R 0
1 / 2 = 0 R 1
Read from bottom
to top: 100101B
7
The Hexadecimal Number System
Name
• “hexa” (Greek) => six
• “decem” (Latin) => ten
Characteristics
• Sixteen symbols
• 0 1 2 3 4 5 6 7 8 9 A B C D E F
• Positional
• A13DH ≠ 3DA1H
Computer programmers often use the hexadecimal number
system
Why?
8
Decimal-Hexadecimal Equivalence
9
Decimal Hex Decimal Hex Decimal Hex
0 0 16 10 32 20
1 1 17 11 33 21
2 2 18 12 34 22
3 3 19 13 35 23
4 4 20 14 36 24
5 5 21 15 37 25
6 6 22 16 38 26
7 7 23 17 39 27
8 8 24 18 40 28
9 9 25 19 41 29
10 A 26 1A 42 2A
11 B 27 1B 43 2B
12 C 28 1C 44 2C
13 D 29 1D 45 2D
14 E 30 1E 46 2E
15 F 31 1F 47 2F
... ...
Decimal-Hexadecimal Conversion
Hexadecimal to decimal: expand using positional notation
Decimal to hexadecimal: use the shortcut
25H = (2*161) +
= 32 +
(5*160)
5
= 37
37 / 16 = 2 R 5
2 / 16 = 0 R 2
Read from bottom
to top: 25H
10
Binary-Hexadecimal Conversion
Observation: 161 = 24
• Every 1 hexadecimal digit corresponds to 4 binary digits
Binary to hexadecimal
1010000100111101B
A 1 3 DH
Digit count in binary number
not a multiple of 4 =>
pad with zeros on left
Hexadecimal to binary
A 1 3 DH
1010000100111101B
Discard leading zeros
from binary number if
appropriate
Is it clear why programmers
often use hexadecimal?
11
The Octal Number System
Name
• “octo” (Latin) => eight
Characteristics
• Eight symbols
• 0 1 2 3 4 5 6 7
• Positional
• 1743O ≠ 7314O
Computer programmers often use the octal number system
Why?
12
Decimal-Octal Equivalence
13
Decimal Octal Decimal Octal Decimal Octal
0 0 16 20 32 40
1 1 17 21 33 41
2 2 18 22 34 42
3 3 19 23 35 43
4 4 20 24 36 44
5 5 21 25 37 45
6 6 22 26 38 46
7 7 23 27 39 47
8 10 24 30 40 50
9 11 25 31 41 51
10 12 26 32 42 52
11 13 27 33 43 53
12 14 28 34 44 54
13 15 29 35 45 55
14 16 30 36 46 56
15 17 31 37 47 57
... ...
Decimal-Octal Conversion
Octal to decimal: expand using positional notation
Decimal to octal: use the shortcut
37O = (3*81) + (7*80)
= 24 + 7
= 31
31 / 8 = 3 R 7
3 / 8 = 0 R 3
Read from bottom
to top: 37O
14
Binary-Octal Conversion
Observation: 81 = 23
• Every 1 octal digit corresponds to 3 binary digits
Binary to octal
001010000100111101B
1 2 0 4 7 5O
Digit count in binary number
not a multiple of 3 =>
pad with zeros on left
Discard leading zeros
from binary number if
appropriate
Octal to binary
1 2 0 4 7 5O
001010000100111101B
Is it clear why programmers
sometimes use octal?
15
Unsigned Data Types: Java vs. C
16
Java has type
• int
• Can represent signed integers
C has type:
• signed int
• Can represent signed integers
• int
• Same as signed int
• unsigned int
• Can represent only unsigned integers
To understand C, must consider representation of both
unsigned and signed integers
Representing Unsigned Integers
17
On pretend computer Unsigned
Integer Rep
0 0000
1 0001
2 0010
3 0011
4 0100
5 0101
6 0110
7 0111
8 1000
9 1001
10 1010
11 1011
12 1100
13 1101
14 1110
15 1111
Adding Unsigned Integers
Addition
Results are mod 24
7
+ 10
11
0111B
+ 1010B
1 10001B
1
3 0011B
+ 10
--
+ 1010B
----
13 1101B
Start at right column
Proceed leftward
Carry 1 when necessary
Beware of overflow
How would you
detect overflow
programmatically?
18
Subtracting Unsigned Integers
Subtraction
3
- 10
2
0011B
- 1010B
9 1001B
Results are mod 24
10
- 7
12
0202
1010B
- 0111B
3 0011B
Start at right column
Proceed leftward
Borrow 2 when necessary
Beware of overflow
How would you
detect overflow
programmatically?
19
Signed Magnitude
20
Integer Rep
-7 1111
-6 1110
-5 1101
-4 1100
-3 1011
-2 1010
-1 1001
-0 1000
0 0000
1 0001
2 0010
3 0011
4 0100
5 0101
6 0110
7 0111
Definition
High-order bit indicates sign
0 => positive
1 => negative
Remaining bits indicate magnitude
B B
1101 = -101 = -5
0101B = 101B = 5
Signed Magnitude (cont.)
Integer Rep
-7 1111
-6 1110
-5 1101
-4 1100
-3 1011
-2 1010
-1 1001
-0 1000
0 0000
1 0001
2 0010
3 0011
4
5
6
7
0100
0101
0110
0111
21
Computing negative
neg(x) = flip high order bit of x
neg(0101B) = 1101B
neg(1101B) = 0101B
Pros and cons
+ easy for people to understand
+ symmetric
- two reps of zero
Ones’ Complement
Integer Rep
-7 1000
-6 1001
-5 1010
-4 1011
-3 1100
-2 1101
-1 1110
-0 1111
0 0000
1 0001
2 0010
3 0011
4
5
6
7
0100
0101
0110
0111
22
Definition
High-order bit has weight -7
B
0010B
1010 = (1*-7)+(0*4)+(1*2)+(0*1)
= -5
= (0*-7)+(0*4)+(1*2)+(0*1)
= 2
Ones’ Complement (cont.)
7 0111
- two reps of zero 23
Integer Rep
-7 1000
-6 1001
-5 1010
-4 1011
-3 1100
-2 1101
-1 1110
-0 1111
0 0000
1 0001
2 0010
3 0011
4 0100
5 0101
6 0110
Computing negative
neg(x) = ~x
neg(0101 ) = 1010
B B
Pros and cons
+ symmetric
neg(1010B) = 0101B
Computing negative (alternative)
neg(x) = 1111B - x
neg(0101 ) = 1111 – 0101
B B B
= 1010B
neg(1010B) = 1111B – 1010B
= 0101B
Two’s Complement
35
Integer Rep
-8 1000
-7 1001
-6 1010
-5 1011
-4 1100
-3 1101
-2 1110
-1 1111
0 0000
1 0001
2 0010
3 0011
4 0100
5 0101
6 0110
7 0111
Definition
High-order bit has weight -8
B
0010B
1010 = (1*-8)+(0*4)+(1*2)+(0*1)
= -6
= (0*-8)+(0*4)+(1*2)+(0*1)
= 2
Two’s Complement (cont.)
25
Integer Rep
-8 1000
-7 1001
-6 1010
-5 1011
-4 1100
-3 1101
-2 1110
-1 1111
0 0000
1 0001
2 0010
3 0011
4 0100
5 0101
6 0110
7 0111
Computing negative
neg(x) = ~x + 1
neg(x) = onescomp(x) + 1
neg(0101B) = 1010B + 1 = 1011B
neg(1011B) = 0100B + 1 = 0101B
Pros and cons
- not symmetric
+ one rep of zero
Two’s Complement (cont.)
26
Almost all computers use two’s complement to represent
signed integers
Why?
• Arithmetic is easy
• Will become clear soon
Hereafter, assume two’s complement representation of
signed integers
Adding Signed Integers
38
3
+ 3
11
0011B
+ 0011B
7
+ 1
111
0111B
+ 0001B
-8 1000B
pos + pos pos + pos (overflow)
3
+ -1
1111
0011B
+ 1111B
6 0110B
pos + neg
-3
+ -2
11
1101B
+ 1110B
-5 11011B
2 10010B
neg + neg
-6
+ -5
1 1
1010B
+ 1011B
5 10101B
neg + neg (overflow)
How would you
detect overflow
programmatically?
Subtracting Signed Integers
1
22
3 0011B 3 0011B
- 4 - 0100B + -4 + 1100B
-1 1111B -1 1111B
111
-5 1011B -5 1011
- 2 - 0010B + -2 + 1110
-7 1001B -7 11001
Perform subtraction
with borrows
28
Compute two’s comp
and add
or

More Related Content

Similar to NumberSystems.pptx

UNIT - I.pptx
UNIT - I.pptxUNIT - I.pptx
UNIT - I.pptxamudhak10
 
UNIT - I.pptx
UNIT - I.pptxUNIT - I.pptx
UNIT - I.pptxamudhak10
 
Basic arithmetic, instruction execution and program
Basic arithmetic, instruction execution and programBasic arithmetic, instruction execution and program
Basic arithmetic, instruction execution and programJyotiprakashMishra18
 
digital-logic-design-cs302-power-point-slides-lecture-01.ppt
digital-logic-design-cs302-power-point-slides-lecture-01.pptdigital-logic-design-cs302-power-point-slides-lecture-01.ppt
digital-logic-design-cs302-power-point-slides-lecture-01.pptAsadAli715892
 
2.1 data represent on cpu
2.1 data represent on cpu2.1 data represent on cpu
2.1 data represent on cpuWan Afirah
 
Pertemuan 2 - Sistem Bilangan
Pertemuan 2 - Sistem BilanganPertemuan 2 - Sistem Bilangan
Pertemuan 2 - Sistem Bilanganahmad haidaroh
 
Number system
Number systemNumber system
Number systemkashee99
 
Video lectures
Video lecturesVideo lectures
Video lecturesEdhole.com
 
Kaizen cso002 l1
Kaizen cso002 l1Kaizen cso002 l1
Kaizen cso002 l1asslang
 
01.number systems
01.number systems01.number systems
01.number systemsrasha3
 
Finite word length effects
Finite word length effectsFinite word length effects
Finite word length effectsPeriyanayagiS
 

Similar to NumberSystems.pptx (20)

number system
number systemnumber system
number system
 
Cse115 lecture01numbersystems
Cse115 lecture01numbersystemsCse115 lecture01numbersystems
Cse115 lecture01numbersystems
 
Alu1
Alu1Alu1
Alu1
 
UNIT - I.pptx
UNIT - I.pptxUNIT - I.pptx
UNIT - I.pptx
 
UNIT - I.pptx
UNIT - I.pptxUNIT - I.pptx
UNIT - I.pptx
 
bits.ppt
bits.pptbits.ppt
bits.ppt
 
Basic arithmetic, instruction execution and program
Basic arithmetic, instruction execution and programBasic arithmetic, instruction execution and program
Basic arithmetic, instruction execution and program
 
Digital Electronics Notes.pdf
Digital Electronics Notes.pdfDigital Electronics Notes.pdf
Digital Electronics Notes.pdf
 
digital-logic-design-cs302-power-point-slides-lecture-01.ppt
digital-logic-design-cs302-power-point-slides-lecture-01.pptdigital-logic-design-cs302-power-point-slides-lecture-01.ppt
digital-logic-design-cs302-power-point-slides-lecture-01.ppt
 
2.1 data represent on cpu
2.1 data represent on cpu2.1 data represent on cpu
2.1 data represent on cpu
 
Pertemuan 2 - Sistem Bilangan
Pertemuan 2 - Sistem BilanganPertemuan 2 - Sistem Bilangan
Pertemuan 2 - Sistem Bilangan
 
Number system
Number systemNumber system
Number system
 
Video lectures
Video lecturesVideo lectures
Video lectures
 
Mba ebooks
Mba ebooksMba ebooks
Mba ebooks
 
Kaizen cso002 l1
Kaizen cso002 l1Kaizen cso002 l1
Kaizen cso002 l1
 
01.number systems
01.number systems01.number systems
01.number systems
 
Finite word length effects
Finite word length effectsFinite word length effects
Finite word length effects
 
Unit 4.docx
Unit 4.docxUnit 4.docx
Unit 4.docx
 
Representation Of Numbers and Characters
Representation Of Numbers and CharactersRepresentation Of Numbers and Characters
Representation Of Numbers and Characters
 
Lec 02
Lec 02Lec 02
Lec 02
 

More from vijayapraba1

C10ComputerEngg.pptx
C10ComputerEngg.pptxC10ComputerEngg.pptx
C10ComputerEngg.pptxvijayapraba1
 
apacheairflow-160827123852.pdf
apacheairflow-160827123852.pdfapacheairflow-160827123852.pdf
apacheairflow-160827123852.pdfvijayapraba1
 
HDFS_architecture.ppt
HDFS_architecture.pptHDFS_architecture.ppt
HDFS_architecture.pptvijayapraba1
 
2 Discovery and Acquisition of Data1.pptx
2 Discovery and Acquisition of Data1.pptx2 Discovery and Acquisition of Data1.pptx
2 Discovery and Acquisition of Data1.pptxvijayapraba1
 
C6ModelingTestingFinalOutputs.pptx
C6ModelingTestingFinalOutputs.pptxC6ModelingTestingFinalOutputs.pptx
C6ModelingTestingFinalOutputs.pptxvijayapraba1
 
C3Problems and Brainstorming.ppt
C3Problems and Brainstorming.pptC3Problems and Brainstorming.ppt
C3Problems and Brainstorming.pptvijayapraba1
 
logic gates ppt.pptx
logic gates ppt.pptxlogic gates ppt.pptx
logic gates ppt.pptxvijayapraba1
 
Combinational_Logic_Circuit_PPT.pptx
Combinational_Logic_Circuit_PPT.pptxCombinational_Logic_Circuit_PPT.pptx
Combinational_Logic_Circuit_PPT.pptxvijayapraba1
 
NumberSystems.pptx
NumberSystems.pptxNumberSystems.pptx
NumberSystems.pptxvijayapraba1
 
logic gates ppt-180430044215.pdf
logic gates ppt-180430044215.pdflogic gates ppt-180430044215.pdf
logic gates ppt-180430044215.pdfvijayapraba1
 
sequential circuits PPT.pdf
sequential circuits PPT.pdfsequential circuits PPT.pdf
sequential circuits PPT.pdfvijayapraba1
 
Fundamentals of Programming Constructs.pptx
Fundamentals of  Programming Constructs.pptxFundamentals of  Programming Constructs.pptx
Fundamentals of Programming Constructs.pptxvijayapraba1
 

More from vijayapraba1 (15)

HBase.pptx
HBase.pptxHBase.pptx
HBase.pptx
 
C10ComputerEngg.pptx
C10ComputerEngg.pptxC10ComputerEngg.pptx
C10ComputerEngg.pptx
 
apacheairflow-160827123852.pdf
apacheairflow-160827123852.pdfapacheairflow-160827123852.pdf
apacheairflow-160827123852.pdf
 
HDFS_architecture.ppt
HDFS_architecture.pptHDFS_architecture.ppt
HDFS_architecture.ppt
 
2 Discovery and Acquisition of Data1.pptx
2 Discovery and Acquisition of Data1.pptx2 Discovery and Acquisition of Data1.pptx
2 Discovery and Acquisition of Data1.pptx
 
C6ModelingTestingFinalOutputs.pptx
C6ModelingTestingFinalOutputs.pptxC6ModelingTestingFinalOutputs.pptx
C6ModelingTestingFinalOutputs.pptx
 
C3Problems and Brainstorming.ppt
C3Problems and Brainstorming.pptC3Problems and Brainstorming.ppt
C3Problems and Brainstorming.ppt
 
ch13_extsort.ppt
ch13_extsort.pptch13_extsort.ppt
ch13_extsort.ppt
 
logic gates ppt.pptx
logic gates ppt.pptxlogic gates ppt.pptx
logic gates ppt.pptx
 
Combinational_Logic_Circuit_PPT.pptx
Combinational_Logic_Circuit_PPT.pptxCombinational_Logic_Circuit_PPT.pptx
Combinational_Logic_Circuit_PPT.pptx
 
NumberSystems.pptx
NumberSystems.pptxNumberSystems.pptx
NumberSystems.pptx
 
DA-Module 1.pptx
DA-Module 1.pptxDA-Module 1.pptx
DA-Module 1.pptx
 
logic gates ppt-180430044215.pdf
logic gates ppt-180430044215.pdflogic gates ppt-180430044215.pdf
logic gates ppt-180430044215.pdf
 
sequential circuits PPT.pdf
sequential circuits PPT.pdfsequential circuits PPT.pdf
sequential circuits PPT.pdf
 
Fundamentals of Programming Constructs.pptx
Fundamentals of  Programming Constructs.pptxFundamentals of  Programming Constructs.pptx
Fundamentals of Programming Constructs.pptx
 

Recently uploaded

Processing & Properties of Floor and Wall Tiles.pptx
Processing & Properties of Floor and Wall Tiles.pptxProcessing & Properties of Floor and Wall Tiles.pptx
Processing & Properties of Floor and Wall Tiles.pptxpranjaldaimarysona
 
(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...ranjana rawat
 
GDSC ASEB Gen AI study jams presentation
GDSC ASEB Gen AI study jams presentationGDSC ASEB Gen AI study jams presentation
GDSC ASEB Gen AI study jams presentationGDSCAESB
 
Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...
Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...
Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...Christo Ananth
 
HARDNESS, FRACTURE TOUGHNESS AND STRENGTH OF CERAMICS
HARDNESS, FRACTURE TOUGHNESS AND STRENGTH OF CERAMICSHARDNESS, FRACTURE TOUGHNESS AND STRENGTH OF CERAMICS
HARDNESS, FRACTURE TOUGHNESS AND STRENGTH OF CERAMICSRajkumarAkumalla
 
VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130
VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130
VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130Suhani Kapoor
 
(PRIYA) Rajgurunagar Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(PRIYA) Rajgurunagar Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...(PRIYA) Rajgurunagar Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(PRIYA) Rajgurunagar Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...ranjana rawat
 
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptx
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptxDecoding Kotlin - Your guide to solving the mysterious in Kotlin.pptx
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptxJoão Esperancinha
 
chaitra-1.pptx fake news detection using machine learning
chaitra-1.pptx  fake news detection using machine learningchaitra-1.pptx  fake news detection using machine learning
chaitra-1.pptx fake news detection using machine learningmisbanausheenparvam
 
Extrusion Processes and Their Limitations
Extrusion Processes and Their LimitationsExtrusion Processes and Their Limitations
Extrusion Processes and Their Limitations120cr0395
 
(RIA) Call Girls Bhosari ( 7001035870 ) HI-Fi Pune Escorts Service
(RIA) Call Girls Bhosari ( 7001035870 ) HI-Fi Pune Escorts Service(RIA) Call Girls Bhosari ( 7001035870 ) HI-Fi Pune Escorts Service
(RIA) Call Girls Bhosari ( 7001035870 ) HI-Fi Pune Escorts Serviceranjana rawat
 
Architect Hassan Khalil Portfolio for 2024
Architect Hassan Khalil Portfolio for 2024Architect Hassan Khalil Portfolio for 2024
Architect Hassan Khalil Portfolio for 2024hassan khalil
 
the ladakh protest in leh ladakh 2024 sonam wangchuk.pptx
the ladakh protest in leh ladakh 2024 sonam wangchuk.pptxthe ladakh protest in leh ladakh 2024 sonam wangchuk.pptx
the ladakh protest in leh ladakh 2024 sonam wangchuk.pptxhumanexperienceaaa
 
SPICE PARK APR2024 ( 6,793 SPICE Models )
SPICE PARK APR2024 ( 6,793 SPICE Models )SPICE PARK APR2024 ( 6,793 SPICE Models )
SPICE PARK APR2024 ( 6,793 SPICE Models )Tsuyoshi Horigome
 
The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...
The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...
The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...ranjana rawat
 

Recently uploaded (20)

Processing & Properties of Floor and Wall Tiles.pptx
Processing & Properties of Floor and Wall Tiles.pptxProcessing & Properties of Floor and Wall Tiles.pptx
Processing & Properties of Floor and Wall Tiles.pptx
 
(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
 
GDSC ASEB Gen AI study jams presentation
GDSC ASEB Gen AI study jams presentationGDSC ASEB Gen AI study jams presentation
GDSC ASEB Gen AI study jams presentation
 
Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...
Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...
Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...
 
HARDNESS, FRACTURE TOUGHNESS AND STRENGTH OF CERAMICS
HARDNESS, FRACTURE TOUGHNESS AND STRENGTH OF CERAMICSHARDNESS, FRACTURE TOUGHNESS AND STRENGTH OF CERAMICS
HARDNESS, FRACTURE TOUGHNESS AND STRENGTH OF CERAMICS
 
VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130
VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130
VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130
 
Call Us -/9953056974- Call Girls In Vikaspuri-/- Delhi NCR
Call Us -/9953056974- Call Girls In Vikaspuri-/- Delhi NCRCall Us -/9953056974- Call Girls In Vikaspuri-/- Delhi NCR
Call Us -/9953056974- Call Girls In Vikaspuri-/- Delhi NCR
 
(PRIYA) Rajgurunagar Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(PRIYA) Rajgurunagar Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...(PRIYA) Rajgurunagar Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(PRIYA) Rajgurunagar Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
 
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptx
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptxDecoding Kotlin - Your guide to solving the mysterious in Kotlin.pptx
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptx
 
★ CALL US 9953330565 ( HOT Young Call Girls In Badarpur delhi NCR
★ CALL US 9953330565 ( HOT Young Call Girls In Badarpur delhi NCR★ CALL US 9953330565 ( HOT Young Call Girls In Badarpur delhi NCR
★ CALL US 9953330565 ( HOT Young Call Girls In Badarpur delhi NCR
 
chaitra-1.pptx fake news detection using machine learning
chaitra-1.pptx  fake news detection using machine learningchaitra-1.pptx  fake news detection using machine learning
chaitra-1.pptx fake news detection using machine learning
 
Extrusion Processes and Their Limitations
Extrusion Processes and Their LimitationsExtrusion Processes and Their Limitations
Extrusion Processes and Their Limitations
 
Roadmap to Membership of RICS - Pathways and Routes
Roadmap to Membership of RICS - Pathways and RoutesRoadmap to Membership of RICS - Pathways and Routes
Roadmap to Membership of RICS - Pathways and Routes
 
(RIA) Call Girls Bhosari ( 7001035870 ) HI-Fi Pune Escorts Service
(RIA) Call Girls Bhosari ( 7001035870 ) HI-Fi Pune Escorts Service(RIA) Call Girls Bhosari ( 7001035870 ) HI-Fi Pune Escorts Service
(RIA) Call Girls Bhosari ( 7001035870 ) HI-Fi Pune Escorts Service
 
Architect Hassan Khalil Portfolio for 2024
Architect Hassan Khalil Portfolio for 2024Architect Hassan Khalil Portfolio for 2024
Architect Hassan Khalil Portfolio for 2024
 
9953056974 Call Girls In South Ex, Escorts (Delhi) NCR.pdf
9953056974 Call Girls In South Ex, Escorts (Delhi) NCR.pdf9953056974 Call Girls In South Ex, Escorts (Delhi) NCR.pdf
9953056974 Call Girls In South Ex, Escorts (Delhi) NCR.pdf
 
the ladakh protest in leh ladakh 2024 sonam wangchuk.pptx
the ladakh protest in leh ladakh 2024 sonam wangchuk.pptxthe ladakh protest in leh ladakh 2024 sonam wangchuk.pptx
the ladakh protest in leh ladakh 2024 sonam wangchuk.pptx
 
SPICE PARK APR2024 ( 6,793 SPICE Models )
SPICE PARK APR2024 ( 6,793 SPICE Models )SPICE PARK APR2024 ( 6,793 SPICE Models )
SPICE PARK APR2024 ( 6,793 SPICE Models )
 
The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...
The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...
The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...
 
Exploring_Network_Security_with_JA3_by_Rakesh Seal.pptx
Exploring_Network_Security_with_JA3_by_Rakesh Seal.pptxExploring_Network_Security_with_JA3_by_Rakesh Seal.pptx
Exploring_Network_Security_with_JA3_by_Rakesh Seal.pptx
 

NumberSystems.pptx

  • 2. The Decimal Number System Name • “decem” (Latin) => ten Characteristics • Ten symbols • 0 1 2 3 4 5 6 7 8 9 • Positional • 2945 ≠ 2495 • 2945 = (2*103) + (9*102) + (4*101) + (5*100) (Most) people use the decimal number system Why? 2
  • 3. The Binary Number System Name • “binarius” (Latin) => two Characteristics • Two symbols • 0 1 • Positional • 1010B ≠ 1100B Most (digital) computers use the binary number system Why? Terminology • Bit: a binary digit • Byte: (typically) 8 bits 3
  • 4. Decimal-Binary Equivalence 4 Decimal Binary Decimal Binary 0 0 16 10000 1 1 17 10001 2 10 18 10010 3 11 19 10011 4 100 20 10100 5 101 21 10101 6 110 22 10110 7 111 23 10111 8 1000 24 11000 9 1001 25 11001 10 1010 26 11010 11 1011 27 11011 12 1100 28 11100 13 1101 29 11101 14 1110 30 11110 15 1111 31 11111 ... ...
  • 5. Decimal-Binary Conversion 5 Binary to decimal: expand using positional notation (1*25)+(0*24)+(0*23)+(1*22)+ 100101B = = 32 + 0 + 0 + 4 + (0*21)+(1*20 ) 0 + 1 = 37
  • 6. Decimal-Binary Conversion 6 Decimal to binary: do the reverse • Determine largest power of 2 ≤ number; write template • Fill in template 37 = (?*25)+(?*24)+(?*23)+(?*22)+(?*21)+(?*20) 37 = (1*25)+(0*24)+(0*23)+(1*22)+(0*21)+(1*20) -32 5 -4 1 100101B -1 0
  • 7. Decimal-Binary Conversion Decimal to binary shortcut • Repeatedly divide by 2, consider remainder 37 / 2 = 18 R 1 18 / 2 = 9 R 0 9 / 2 = 4 R 1 4 / 2 = 2 R 0 2 / 2 = 1 R 0 1 / 2 = 0 R 1 Read from bottom to top: 100101B 7
  • 8. The Hexadecimal Number System Name • “hexa” (Greek) => six • “decem” (Latin) => ten Characteristics • Sixteen symbols • 0 1 2 3 4 5 6 7 8 9 A B C D E F • Positional • A13DH ≠ 3DA1H Computer programmers often use the hexadecimal number system Why? 8
  • 9. Decimal-Hexadecimal Equivalence 9 Decimal Hex Decimal Hex Decimal Hex 0 0 16 10 32 20 1 1 17 11 33 21 2 2 18 12 34 22 3 3 19 13 35 23 4 4 20 14 36 24 5 5 21 15 37 25 6 6 22 16 38 26 7 7 23 17 39 27 8 8 24 18 40 28 9 9 25 19 41 29 10 A 26 1A 42 2A 11 B 27 1B 43 2B 12 C 28 1C 44 2C 13 D 29 1D 45 2D 14 E 30 1E 46 2E 15 F 31 1F 47 2F ... ...
  • 10. Decimal-Hexadecimal Conversion Hexadecimal to decimal: expand using positional notation Decimal to hexadecimal: use the shortcut 25H = (2*161) + = 32 + (5*160) 5 = 37 37 / 16 = 2 R 5 2 / 16 = 0 R 2 Read from bottom to top: 25H 10
  • 11. Binary-Hexadecimal Conversion Observation: 161 = 24 • Every 1 hexadecimal digit corresponds to 4 binary digits Binary to hexadecimal 1010000100111101B A 1 3 DH Digit count in binary number not a multiple of 4 => pad with zeros on left Hexadecimal to binary A 1 3 DH 1010000100111101B Discard leading zeros from binary number if appropriate Is it clear why programmers often use hexadecimal? 11
  • 12. The Octal Number System Name • “octo” (Latin) => eight Characteristics • Eight symbols • 0 1 2 3 4 5 6 7 • Positional • 1743O ≠ 7314O Computer programmers often use the octal number system Why? 12
  • 13. Decimal-Octal Equivalence 13 Decimal Octal Decimal Octal Decimal Octal 0 0 16 20 32 40 1 1 17 21 33 41 2 2 18 22 34 42 3 3 19 23 35 43 4 4 20 24 36 44 5 5 21 25 37 45 6 6 22 26 38 46 7 7 23 27 39 47 8 10 24 30 40 50 9 11 25 31 41 51 10 12 26 32 42 52 11 13 27 33 43 53 12 14 28 34 44 54 13 15 29 35 45 55 14 16 30 36 46 56 15 17 31 37 47 57 ... ...
  • 14. Decimal-Octal Conversion Octal to decimal: expand using positional notation Decimal to octal: use the shortcut 37O = (3*81) + (7*80) = 24 + 7 = 31 31 / 8 = 3 R 7 3 / 8 = 0 R 3 Read from bottom to top: 37O 14
  • 15. Binary-Octal Conversion Observation: 81 = 23 • Every 1 octal digit corresponds to 3 binary digits Binary to octal 001010000100111101B 1 2 0 4 7 5O Digit count in binary number not a multiple of 3 => pad with zeros on left Discard leading zeros from binary number if appropriate Octal to binary 1 2 0 4 7 5O 001010000100111101B Is it clear why programmers sometimes use octal? 15
  • 16. Unsigned Data Types: Java vs. C 16 Java has type • int • Can represent signed integers C has type: • signed int • Can represent signed integers • int • Same as signed int • unsigned int • Can represent only unsigned integers To understand C, must consider representation of both unsigned and signed integers
  • 17. Representing Unsigned Integers 17 On pretend computer Unsigned Integer Rep 0 0000 1 0001 2 0010 3 0011 4 0100 5 0101 6 0110 7 0111 8 1000 9 1001 10 1010 11 1011 12 1100 13 1101 14 1110 15 1111
  • 18. Adding Unsigned Integers Addition Results are mod 24 7 + 10 11 0111B + 1010B 1 10001B 1 3 0011B + 10 -- + 1010B ---- 13 1101B Start at right column Proceed leftward Carry 1 when necessary Beware of overflow How would you detect overflow programmatically? 18
  • 19. Subtracting Unsigned Integers Subtraction 3 - 10 2 0011B - 1010B 9 1001B Results are mod 24 10 - 7 12 0202 1010B - 0111B 3 0011B Start at right column Proceed leftward Borrow 2 when necessary Beware of overflow How would you detect overflow programmatically? 19
  • 20. Signed Magnitude 20 Integer Rep -7 1111 -6 1110 -5 1101 -4 1100 -3 1011 -2 1010 -1 1001 -0 1000 0 0000 1 0001 2 0010 3 0011 4 0100 5 0101 6 0110 7 0111 Definition High-order bit indicates sign 0 => positive 1 => negative Remaining bits indicate magnitude B B 1101 = -101 = -5 0101B = 101B = 5
  • 21. Signed Magnitude (cont.) Integer Rep -7 1111 -6 1110 -5 1101 -4 1100 -3 1011 -2 1010 -1 1001 -0 1000 0 0000 1 0001 2 0010 3 0011 4 5 6 7 0100 0101 0110 0111 21 Computing negative neg(x) = flip high order bit of x neg(0101B) = 1101B neg(1101B) = 0101B Pros and cons + easy for people to understand + symmetric - two reps of zero
  • 22. Ones’ Complement Integer Rep -7 1000 -6 1001 -5 1010 -4 1011 -3 1100 -2 1101 -1 1110 -0 1111 0 0000 1 0001 2 0010 3 0011 4 5 6 7 0100 0101 0110 0111 22 Definition High-order bit has weight -7 B 0010B 1010 = (1*-7)+(0*4)+(1*2)+(0*1) = -5 = (0*-7)+(0*4)+(1*2)+(0*1) = 2
  • 23. Ones’ Complement (cont.) 7 0111 - two reps of zero 23 Integer Rep -7 1000 -6 1001 -5 1010 -4 1011 -3 1100 -2 1101 -1 1110 -0 1111 0 0000 1 0001 2 0010 3 0011 4 0100 5 0101 6 0110 Computing negative neg(x) = ~x neg(0101 ) = 1010 B B Pros and cons + symmetric neg(1010B) = 0101B Computing negative (alternative) neg(x) = 1111B - x neg(0101 ) = 1111 – 0101 B B B = 1010B neg(1010B) = 1111B – 1010B = 0101B
  • 24. Two’s Complement 35 Integer Rep -8 1000 -7 1001 -6 1010 -5 1011 -4 1100 -3 1101 -2 1110 -1 1111 0 0000 1 0001 2 0010 3 0011 4 0100 5 0101 6 0110 7 0111 Definition High-order bit has weight -8 B 0010B 1010 = (1*-8)+(0*4)+(1*2)+(0*1) = -6 = (0*-8)+(0*4)+(1*2)+(0*1) = 2
  • 25. Two’s Complement (cont.) 25 Integer Rep -8 1000 -7 1001 -6 1010 -5 1011 -4 1100 -3 1101 -2 1110 -1 1111 0 0000 1 0001 2 0010 3 0011 4 0100 5 0101 6 0110 7 0111 Computing negative neg(x) = ~x + 1 neg(x) = onescomp(x) + 1 neg(0101B) = 1010B + 1 = 1011B neg(1011B) = 0100B + 1 = 0101B Pros and cons - not symmetric + one rep of zero
  • 26. Two’s Complement (cont.) 26 Almost all computers use two’s complement to represent signed integers Why? • Arithmetic is easy • Will become clear soon Hereafter, assume two’s complement representation of signed integers
  • 27. Adding Signed Integers 38 3 + 3 11 0011B + 0011B 7 + 1 111 0111B + 0001B -8 1000B pos + pos pos + pos (overflow) 3 + -1 1111 0011B + 1111B 6 0110B pos + neg -3 + -2 11 1101B + 1110B -5 11011B 2 10010B neg + neg -6 + -5 1 1 1010B + 1011B 5 10101B neg + neg (overflow) How would you detect overflow programmatically?
  • 28. Subtracting Signed Integers 1 22 3 0011B 3 0011B - 4 - 0100B + -4 + 1100B -1 1111B -1 1111B 111 -5 1011B -5 1011 - 2 - 0010B + -2 + 1110 -7 1001B -7 11001 Perform subtraction with borrows 28 Compute two’s comp and add or