SlideShare a Scribd company logo
Computer Fundamentals:
Number Systems
Dr Robert Harle
Today's Topics
 The significance of the bit and powers of 2
 Data quantities (B, kB, MB, GB, etc)
 Number systems (decimal, binary, octal , hexadecimal)
 Representing negative numbers (sign-magnitude, 1’s
complement, 2’s complement)
 Binary addition (carries, overflows)
 Binary subtraction
So...
 What is a bit?
The Significance of the Bit
 A bit (Binary digIT) is merely 0 or 1
 It is a unit of information since you cannot communicate
with anything less than two states
 The use of binary encoding dates back to the 1600s with
Jacquard's loom, which created textiles using card
templates with holes that allowed needles through
Bits and Computers
 The nice thing about a bit is that, with only two states, it is
easy to embody in physical machinery
 Each bit is simply a switch and computers moved from
vacuum tubes to transistors for this
e-
Decimal Number System
 Most computers count in binary, which we can easily
understand from the decimal so ingrained in us
35462
Decimal Number System
 Most computers count in binary, which we can easily
understand from the decimal so ingrained in us
35462
2x100
Decimal Number System
 Most computers count in binary, which we can easily
understand from the decimal so ingrained in us
35462
2x100
6x101
+
Decimal Number System
 Most computers count in binary, which we can easily
understand from the decimal so ingrained in us
35462
2x100
6x101
+
4x102
+
Decimal Number System
 Most computers count in binary, which we can easily
understand from the decimal so ingrained in us
35462
2x100
6x101
+
4x102
+
5x103
+
Decimal Number System
 Most computers count in binary, which we can easily
understand from the decimal so ingrained in us
35462
2x100
6x101
+
4x102
+
5x103
+
3x104
+
Binary
 Binary is exactly the same, only instead of ten
digits/states (0 to 9) we have just two, so the base
becomes 2:
10110
0x20
1x21
+
1x22
+
0x23
+
1x24
+
Binary
 Binary is exactly the same, only instead of ten
digits/states (0 to 9) we have just two, so the base
becomes 2:
10110b
= 22d
0x20
1x21
+
1x22
+
0x23
+
1x24
+
Binary
 Binary is exactly the same, only instead of ten
digits/states (0 to 9) we have just two, so the base
becomes 2:
10110b
= 22d
0x20
1x21
+
1x22
+
0x23
+
1x24
+
Most Significant
Bit (MSB)
Least Significant
Bit (LSB)
Works for Fractional Numbers too...
35.462
2x10-3
6x10-2
+
4x10-1
+
5x100
+
3x101
+
Works for Fractional Numbers too...
10.110b
= 2.75d
0x2-3
1x2-2
+
1x2-1
+
0x20
+
1x21
+
35.462
2x10-3
6x10-2
+
4x10-1
+
5x100
+
3x101
+
Check
11.011b
Check
11.011b
= 3.375d
1x2-3
1x2-2
+
0x2-1
+
1x20
+
1x21
+
Representable Numbers
 With d decimal digits, we can represent 10d
different
values, usually the numbers 0 to (10d
-1) inclusive
 In binary with n bits this becomes 2n
values, usually
the range 0 to (2n
-1)
 Computers usually assign a set number of bits
(physical switches) to an instance of a type.
 An integer is often 32 bits, so can represent
positive integers from 0 to 4,294,967,295 incl.
 Or a range of negative and positive integers...
Other Common Bases
 Higher bases make for shorter numbers that are easier for
humans to manipulate. e.g.
6654733d
=11001011000101100001101b
 We traditionally choose powers-of-2 bases because this
corresponds to whole chunks of binary
Other Common Bases
 Higher bases make for shorter numbers that are easier for
humans to manipulate. e.g.
6654733d
=11001011000101100001101b
 We traditionally choose powers-of-2 bases because this
corresponds to whole chunks of binary
 Octal is base-8 (8=23
digits, which means 3 bits per digit)
 6654733d
=011-001-011-000-101-100-001-101b
= 31305415o
Other Common Bases
 Higher bases make for shorter numbers that are easier for
humans to manipulate. e.g.
6654733d
=11001011000101100001101b
 We traditionally choose powers-of-2 bases because this
corresponds to whole chunks of binary
 Octal is base-8 (8=23
digits, which means 3 bits per digit)
 6654733d
=011-001-011-000-101-100-001-101b
= 31305415o
 Hexadecimal is base-16 (16=24
digits so 4 bits per digit)
 Our ten decimal digits aren't enough, so we add 6 new
ones: 0,1,2,3,4,5,6,7,8,9,A,B,C,D,E,F
 6654733d
=0110-0101-1000-1011-0000-1101b
=658B0Dh
Other Common Bases
 Higher bases make for shorter numbers that are easier for
humans to manipulate. e.g.
6654733d
=11001011000101100001101b
 We traditionally choose powers-of-2 bases because this
corresponds to whole chunks of binary
 Octal is base-8 (8=23
digits, which means 3 bits per digit)
 6654733d
=011-001-011-000-101-100-001-101b
= 31305415o
 Hexadecimal is base-16 (16=24
digits so 4 bits per digit)
 Our ten decimal digits aren't enough, so we add 6 new
ones: 0,1,2,3,4,5,6,7,8,9,A,B,C,D,E,F
 6654733d
=0110-0101-1000-1011-0000-1101b
=658B0Dh
 Because we constantly slip between binary and hex, we have
a special marker for it
 Prefix with '0x' (zero-x). So 0x658B0D=6654733d
, 0x123=291d
Bytes
 A byte was traditionally the number of bits needed to
store a character of text
 A de-facto standard of 8 bits has now emerged
 256 values
 0 to 255 incl.
 Two hex digits to describe
 0x00=0, 0xFF=255
 Check: what does 0xBD represent?
Bytes
 A byte was traditionally the number of bits needed to
store a character of text
 A de-facto standard of 8 bits has now emerged
 256 values
 0 to 255 incl.
 Two hex digits to describe
 0x00=0, 0xFF=255
 Check: what does 0xBD represent?
 B → 11 or 1011
 D → 13 or 1101
 Result is 11x161
+13x160
= 189 or 10111101
Larger Units
 Strictly the SI units since 1998 are:
 Kibibyte (KiB)
 1024 bytes (closest power of 2 to 1000)
 Mebibyte (MiB)
 1,048,576 bytes
 Gibibyte (GiB)
 1,073,741,824 bytes
Larger Units
 Strictly the SI units since 1998 are:
 Kibibyte (KiB)
 1024 bytes (closest power of 2 to 1000)
 Mebibyte (MiB)
 1,048,576 bytes
 Gibibyte (GiB)
 1,073,741,824 bytes
 but these haven't really caught on so we tend to still use the SI
Kilobyte, Megabyte, Gigabyte. This leads to lots of confusion
since technically these are multiples of 1,000.
The Problem with Ten
Unsigned Integer Addition
 Addition of unsigned integers works the same way as
addition of decimal (only simpler!)
 0 + 0 = 0
 0 + 1 = 1
 1 + 0 = 1
 1 + 1 = 0, carry 1
 Only issue is that computers have fixed sized types so we
can't go on adding forever...
111
+ 001
001
+ 001
Carry flag: Carry flag:
Modulo or Clock Arithmetic
 Overflow takes us across the dotted
boundary
 So 7+1=0 (overflow)
 We say this is (7+1) mod 8
000
001
010
011
100
101
110
111
000
001
010
011
100
101
110
111
Negative Numbers
 All of this skipped over the need to represent
negatives.
 The naïve choice is to use the MSB to indicate +/-
 1 in the MSB → negative
 0 in the MSB → positive
 This is the sign-magnitude technique
-7 = 1111
Negative
Normal positive
representation of 7
Difficulties with Sign-Magnitude
 Has a representation of minus zero (10002
=-0) so
wastes one of our 2n
labels
 Addition/subtraction circuitry must be designed
from scratch
1101
+ 0001
1110
Our unsigned addition alg.
Difficulties with Sign-Magnitude
 Has a representation of minus zero (10002
=-0) so
wastes one of our 2n
labels
 Addition/subtraction circuitry must be designed
from scratch
1101
+ 0001
1110
Our unsigned addition alg.
+13
+1
+14
Unsigned
interpretation
Difficulties with Sign-Magnitude
 Has a representation of minus zero (10002
=-0) so
wastes one of our 2n
labels
 Addition/subtraction circuitry must be designed
from scratch
1101
+ 0001
1110
-5
+1
-6
+13
+1
+14
Sign-mag
interpretation
Unsigned
interpretation
Our unsigned addition alg.
Alternatively...
 Gives us two discontinuities and a
reversal of direction using normal
addition circuitry!!
000
001
010
011
100
101
110
111 000
001
010
011
100
101
110
111
Ones' Complement
 The negative is the positive with all the bits flipped
 7 → 0111 so -7 → 1000
 Still the MSB is the sign
 One discontinuity but still -0 :-(
000
001
010
011
100
101
110
111 000
001
010
011
100
101
110
111
Two's Complement
 The negative is the positive with all the bits flipped
and 1 added (the same procedure for the inverse)
 7 → 0111 so -7 → 1000+0001 → 1001
 Still the MSB is the sign
 One discontinuity and proper ordering
000
001
010
011
100
101
110
111
000
001
010
011
100
101
110
111
Two's Complement
 Positive to negative: Invert all the bits and add 1
 Negative to positive: Same procedure!!
1011 (-5) → 0100 → 0101 (+5)
0101 (+5) → 1010 → 1011 (-5)
Signed Addition
1101
+0001
1110
Our unsigned addition alg.
 ...it just works with our addition algorithm!
+13
+1
+14
Unsigned
Signed Addition
1101
+0001
1110
-3
+1
-2
+13
+1
+14
2's-comp Unsigned
Our unsigned addition alg.
 ...it just works with our addition algorithm!
Signed Addition
1101
+0001
1110
-3
+1
-2
+13
+1
+14
2's-comp Unsigned
Our unsigned addition alg.
 ...it just works with our addition algorithm!
 So we can use the same circuitry for unsigned and 2s-
complement addition :-)
 Well, almost.
Signed Addition
0100
+0100
1000
+4
+4
+8
Unsigned
Carry flag: 0
 So we can use the same circuitry for unsigned and 2s-
complement addition :-)
 Well, almost.
 The problem is our MSB is now signifying the sign and our carry
should really be testing the bit to its right :-(
Signed Addition
0100
+0100
1000
+4
+4
-8
+4
+4
+8
2's-comp Unsigned
Carry flag: 0
 So we can use the same circuitry for unsigned and 2s-
complement addition :-)
 Well, almost.
 The problem is our MSB is now signifying the sign and our carry
should really be testing the bit to its right :-(
 So we introduce an overflow flag that indicates this problem
Signed Addition
0100
+0100
1000
+4
+4
-8
+4
+4
+8
2's-comp Unsigned
Carry flag: 0
Overflow: 1
Integer subtraction
 Could implement the “borrowing”
algorithm you probably learnt in school
 But why bother? We can just add the
2's complement instead.
0100
- 0011
0100
+1101
0001
→
Flags Summary
 When adding/subtracting
 Carry flag → overflow for unsigned integer
 Overflow flag → overflow for signed integer
 The CPU does not care whether it's
handling signed or unsigned integers
 Down to our compilers/programs to
interpret the result
Fractional Numbers
 Scientific apps rarely survive on integers alone, but
representing fractional parts efficiently is
complicated.
 Option one: fixed point
 Set the point at a known location. Anything to
the left represents the integer part; anything to
the right the fractional part
 But where do we set it??
 Option two: floating point
 Let the point 'float' to give more capacity on its
left or right as needed
 Much more efficient, but harder to work with
 Very important: more in Numerical Methods
course

More Related Content

Similar to NumberSystemsAnnotated.pdf

Alu1
Alu1Alu1
Logic Design 2009
Logic Design 2009Logic Design 2009
Logic Design 2009
lionking
 
Pertemuan 2 - Sistem Bilangan
Pertemuan 2 - Sistem BilanganPertemuan 2 - Sistem Bilangan
Pertemuan 2 - Sistem Bilangan
ahmad haidaroh
 
Arithmetic.ppt
Arithmetic.pptArithmetic.ppt
Arithmetic.ppt
MarlonMagtibay2
 
digitalelectronics.ppt
digitalelectronics.pptdigitalelectronics.ppt
digitalelectronics.ppt
HarshalVaidya11
 
ch3a-binary-numbers.ppt
ch3a-binary-numbers.pptch3a-binary-numbers.ppt
ch3a-binary-numbers.ppt
MUNAZARAZZAQELEA
 
Number System.pdf
Number System.pdfNumber System.pdf
Number System.pdf
Sweta Kumari Barnwal
 
ch3a-binary-numbers.ppt
ch3a-binary-numbers.pptch3a-binary-numbers.ppt
ch3a-binary-numbers.ppt
RabiaAsif31
 
Data Representation
Data RepresentationData Representation
Data Representation
Education Front
 
Data types - things you have to know!
Data types - things you have to know!Data types - things you have to know!
Data types - things you have to know!
Karol Sobiesiak
 
ch3a-binary-numbers.ppt
ch3a-binary-numbers.pptch3a-binary-numbers.ppt
ch3a-binary-numbers.ppt
Suganthi Vasanth Raj
 
ch3a-binary-numbers.ppt
ch3a-binary-numbers.pptch3a-binary-numbers.ppt
ch3a-binary-numbers.ppt
ssuser52a19e
 
ch3a-binary-numbers.ppt
ch3a-binary-numbers.pptch3a-binary-numbers.ppt
ch3a-binary-numbers.ppt
RAJKUMARP63
 
binary-numbers.ppt
binary-numbers.pptbinary-numbers.ppt
binary-numbers.ppt
MarlonMagtibay2
 
Review on Number Systems: Decimal, Binary, and Hexadecimal
Review on Number Systems: Decimal, Binary, and HexadecimalReview on Number Systems: Decimal, Binary, and Hexadecimal
Review on Number Systems: Decimal, Binary, and Hexadecimal
UtkirjonUbaydullaev1
 
08 Numeral systems
08 Numeral systems08 Numeral systems
08 Numeral systems
maznabili
 
Binary octal
Binary octalBinary octal
Binary octaldrdipo4
 
data representation
 data representation data representation
data representation
Haroon_007
 
unit-2_DL.pdf
unit-2_DL.pdfunit-2_DL.pdf
unit-2_DL.pdf
ashoksahu64
 

Similar to NumberSystemsAnnotated.pdf (20)

Alu1
Alu1Alu1
Alu1
 
Logic Design 2009
Logic Design 2009Logic Design 2009
Logic Design 2009
 
Pertemuan 2 - Sistem Bilangan
Pertemuan 2 - Sistem BilanganPertemuan 2 - Sistem Bilangan
Pertemuan 2 - Sistem Bilangan
 
Arithmetic.ppt
Arithmetic.pptArithmetic.ppt
Arithmetic.ppt
 
digitalelectronics.ppt
digitalelectronics.pptdigitalelectronics.ppt
digitalelectronics.ppt
 
ch3a-binary-numbers.ppt
ch3a-binary-numbers.pptch3a-binary-numbers.ppt
ch3a-binary-numbers.ppt
 
Number System.pdf
Number System.pdfNumber System.pdf
Number System.pdf
 
Lec 02
Lec 02Lec 02
Lec 02
 
ch3a-binary-numbers.ppt
ch3a-binary-numbers.pptch3a-binary-numbers.ppt
ch3a-binary-numbers.ppt
 
Data Representation
Data RepresentationData Representation
Data Representation
 
Data types - things you have to know!
Data types - things you have to know!Data types - things you have to know!
Data types - things you have to know!
 
ch3a-binary-numbers.ppt
ch3a-binary-numbers.pptch3a-binary-numbers.ppt
ch3a-binary-numbers.ppt
 
ch3a-binary-numbers.ppt
ch3a-binary-numbers.pptch3a-binary-numbers.ppt
ch3a-binary-numbers.ppt
 
ch3a-binary-numbers.ppt
ch3a-binary-numbers.pptch3a-binary-numbers.ppt
ch3a-binary-numbers.ppt
 
binary-numbers.ppt
binary-numbers.pptbinary-numbers.ppt
binary-numbers.ppt
 
Review on Number Systems: Decimal, Binary, and Hexadecimal
Review on Number Systems: Decimal, Binary, and HexadecimalReview on Number Systems: Decimal, Binary, and Hexadecimal
Review on Number Systems: Decimal, Binary, and Hexadecimal
 
08 Numeral systems
08 Numeral systems08 Numeral systems
08 Numeral systems
 
Binary octal
Binary octalBinary octal
Binary octal
 
data representation
 data representation data representation
data representation
 
unit-2_DL.pdf
unit-2_DL.pdfunit-2_DL.pdf
unit-2_DL.pdf
 

More from MarzCasipong1

MEASURING TOOLS topic grade 9. computer9
MEASURING TOOLS topic grade 9. computer9MEASURING TOOLS topic grade 9. computer9
MEASURING TOOLS topic grade 9. computer9
MarzCasipong1
 
cognitivism.pptx
cognitivism.pptxcognitivism.pptx
cognitivism.pptx
MarzCasipong1
 
multicultural literature1.pptx
multicultural literature1.pptxmulticultural literature1.pptx
multicultural literature1.pptx
MarzCasipong1
 
Learner-Centered-Philosophical-pptx (1).pptx
Learner-Centered-Philosophical-pptx (1).pptxLearner-Centered-Philosophical-pptx (1).pptx
Learner-Centered-Philosophical-pptx (1).pptx
MarzCasipong1
 
CHALLENGES IN ICT-1.pptx
CHALLENGES IN ICT-1.pptxCHALLENGES IN ICT-1.pptx
CHALLENGES IN ICT-1.pptx
MarzCasipong1
 
MULTIcultural literature.pptx
MULTIcultural literature.pptxMULTIcultural literature.pptx
MULTIcultural literature.pptx
MarzCasipong1
 
Research Presentation.pptx
Research Presentation.pptxResearch Presentation.pptx
Research Presentation.pptx
MarzCasipong1
 
LOVE.pptx
LOVE.pptxLOVE.pptx
LOVE.pptx
MarzCasipong1
 
ITEC.pptx
ITEC.pptxITEC.pptx
ITEC.pptx
MarzCasipong1
 

More from MarzCasipong1 (9)

MEASURING TOOLS topic grade 9. computer9
MEASURING TOOLS topic grade 9. computer9MEASURING TOOLS topic grade 9. computer9
MEASURING TOOLS topic grade 9. computer9
 
cognitivism.pptx
cognitivism.pptxcognitivism.pptx
cognitivism.pptx
 
multicultural literature1.pptx
multicultural literature1.pptxmulticultural literature1.pptx
multicultural literature1.pptx
 
Learner-Centered-Philosophical-pptx (1).pptx
Learner-Centered-Philosophical-pptx (1).pptxLearner-Centered-Philosophical-pptx (1).pptx
Learner-Centered-Philosophical-pptx (1).pptx
 
CHALLENGES IN ICT-1.pptx
CHALLENGES IN ICT-1.pptxCHALLENGES IN ICT-1.pptx
CHALLENGES IN ICT-1.pptx
 
MULTIcultural literature.pptx
MULTIcultural literature.pptxMULTIcultural literature.pptx
MULTIcultural literature.pptx
 
Research Presentation.pptx
Research Presentation.pptxResearch Presentation.pptx
Research Presentation.pptx
 
LOVE.pptx
LOVE.pptxLOVE.pptx
LOVE.pptx
 
ITEC.pptx
ITEC.pptxITEC.pptx
ITEC.pptx
 

Recently uploaded

Industrial Training at Shahjalal Fertilizer Company Limited (SFCL)
Industrial Training at Shahjalal Fertilizer Company Limited (SFCL)Industrial Training at Shahjalal Fertilizer Company Limited (SFCL)
Industrial Training at Shahjalal Fertilizer Company Limited (SFCL)
MdTanvirMahtab2
 
J.Yang, ICLR 2024, MLILAB, KAIST AI.pdf
J.Yang,  ICLR 2024, MLILAB, KAIST AI.pdfJ.Yang,  ICLR 2024, MLILAB, KAIST AI.pdf
J.Yang, ICLR 2024, MLILAB, KAIST AI.pdf
MLILAB
 
HYDROPOWER - Hydroelectric power generation
HYDROPOWER - Hydroelectric power generationHYDROPOWER - Hydroelectric power generation
HYDROPOWER - Hydroelectric power generation
Robbie Edward Sayers
 
Pile Foundation by Venkatesh Taduvai (Sub Geotechnical Engineering II)-conver...
Pile Foundation by Venkatesh Taduvai (Sub Geotechnical Engineering II)-conver...Pile Foundation by Venkatesh Taduvai (Sub Geotechnical Engineering II)-conver...
Pile Foundation by Venkatesh Taduvai (Sub Geotechnical Engineering II)-conver...
AJAYKUMARPUND1
 
MCQ Soil mechanics questions (Soil shear strength).pdf
MCQ Soil mechanics questions (Soil shear strength).pdfMCQ Soil mechanics questions (Soil shear strength).pdf
MCQ Soil mechanics questions (Soil shear strength).pdf
Osamah Alsalih
 
Standard Reomte Control Interface - Neometrix
Standard Reomte Control Interface - NeometrixStandard Reomte Control Interface - Neometrix
Standard Reomte Control Interface - Neometrix
Neometrix_Engineering_Pvt_Ltd
 
ethical hacking-mobile hacking methods.ppt
ethical hacking-mobile hacking methods.pptethical hacking-mobile hacking methods.ppt
ethical hacking-mobile hacking methods.ppt
Jayaprasanna4
 
Top 10 Oil and Gas Projects in Saudi Arabia 2024.pdf
Top 10 Oil and Gas Projects in Saudi Arabia 2024.pdfTop 10 Oil and Gas Projects in Saudi Arabia 2024.pdf
Top 10 Oil and Gas Projects in Saudi Arabia 2024.pdf
Teleport Manpower Consultant
 
power quality voltage fluctuation UNIT - I.pptx
power quality voltage fluctuation UNIT - I.pptxpower quality voltage fluctuation UNIT - I.pptx
power quality voltage fluctuation UNIT - I.pptx
ViniHema
 
Hierarchical Digital Twin of a Naval Power System
Hierarchical Digital Twin of a Naval Power SystemHierarchical Digital Twin of a Naval Power System
Hierarchical Digital Twin of a Naval Power System
Kerry Sado
 
block diagram and signal flow graph representation
block diagram and signal flow graph representationblock diagram and signal flow graph representation
block diagram and signal flow graph representation
Divya Somashekar
 
RAT: Retrieval Augmented Thoughts Elicit Context-Aware Reasoning in Long-Hori...
RAT: Retrieval Augmented Thoughts Elicit Context-Aware Reasoning in Long-Hori...RAT: Retrieval Augmented Thoughts Elicit Context-Aware Reasoning in Long-Hori...
RAT: Retrieval Augmented Thoughts Elicit Context-Aware Reasoning in Long-Hori...
thanhdowork
 
ethical hacking in wireless-hacking1.ppt
ethical hacking in wireless-hacking1.pptethical hacking in wireless-hacking1.ppt
ethical hacking in wireless-hacking1.ppt
Jayaprasanna4
 
AP LAB PPT.pdf ap lab ppt no title specific
AP LAB PPT.pdf ap lab ppt no title specificAP LAB PPT.pdf ap lab ppt no title specific
AP LAB PPT.pdf ap lab ppt no title specific
BrazilAccount1
 
一比一原版(SFU毕业证)西蒙菲莎大学毕业证成绩单如何办理
一比一原版(SFU毕业证)西蒙菲莎大学毕业证成绩单如何办理一比一原版(SFU毕业证)西蒙菲莎大学毕业证成绩单如何办理
一比一原版(SFU毕业证)西蒙菲莎大学毕业证成绩单如何办理
bakpo1
 
AKS UNIVERSITY Satna Final Year Project By OM Hardaha.pdf
AKS UNIVERSITY Satna Final Year Project By OM Hardaha.pdfAKS UNIVERSITY Satna Final Year Project By OM Hardaha.pdf
AKS UNIVERSITY Satna Final Year Project By OM Hardaha.pdf
SamSarthak3
 
NO1 Uk best vashikaran specialist in delhi vashikaran baba near me online vas...
NO1 Uk best vashikaran specialist in delhi vashikaran baba near me online vas...NO1 Uk best vashikaran specialist in delhi vashikaran baba near me online vas...
NO1 Uk best vashikaran specialist in delhi vashikaran baba near me online vas...
Amil Baba Dawood bangali
 
H.Seo, ICLR 2024, MLILAB, KAIST AI.pdf
H.Seo,  ICLR 2024, MLILAB,  KAIST AI.pdfH.Seo,  ICLR 2024, MLILAB,  KAIST AI.pdf
H.Seo, ICLR 2024, MLILAB, KAIST AI.pdf
MLILAB
 
Sachpazis:Terzaghi Bearing Capacity Estimation in simple terms with Calculati...
Sachpazis:Terzaghi Bearing Capacity Estimation in simple terms with Calculati...Sachpazis:Terzaghi Bearing Capacity Estimation in simple terms with Calculati...
Sachpazis:Terzaghi Bearing Capacity Estimation in simple terms with Calculati...
Dr.Costas Sachpazis
 
在线办理(ANU毕业证书)澳洲国立大学毕业证录取通知书一模一样
在线办理(ANU毕业证书)澳洲国立大学毕业证录取通知书一模一样在线办理(ANU毕业证书)澳洲国立大学毕业证录取通知书一模一样
在线办理(ANU毕业证书)澳洲国立大学毕业证录取通知书一模一样
obonagu
 

Recently uploaded (20)

Industrial Training at Shahjalal Fertilizer Company Limited (SFCL)
Industrial Training at Shahjalal Fertilizer Company Limited (SFCL)Industrial Training at Shahjalal Fertilizer Company Limited (SFCL)
Industrial Training at Shahjalal Fertilizer Company Limited (SFCL)
 
J.Yang, ICLR 2024, MLILAB, KAIST AI.pdf
J.Yang,  ICLR 2024, MLILAB, KAIST AI.pdfJ.Yang,  ICLR 2024, MLILAB, KAIST AI.pdf
J.Yang, ICLR 2024, MLILAB, KAIST AI.pdf
 
HYDROPOWER - Hydroelectric power generation
HYDROPOWER - Hydroelectric power generationHYDROPOWER - Hydroelectric power generation
HYDROPOWER - Hydroelectric power generation
 
Pile Foundation by Venkatesh Taduvai (Sub Geotechnical Engineering II)-conver...
Pile Foundation by Venkatesh Taduvai (Sub Geotechnical Engineering II)-conver...Pile Foundation by Venkatesh Taduvai (Sub Geotechnical Engineering II)-conver...
Pile Foundation by Venkatesh Taduvai (Sub Geotechnical Engineering II)-conver...
 
MCQ Soil mechanics questions (Soil shear strength).pdf
MCQ Soil mechanics questions (Soil shear strength).pdfMCQ Soil mechanics questions (Soil shear strength).pdf
MCQ Soil mechanics questions (Soil shear strength).pdf
 
Standard Reomte Control Interface - Neometrix
Standard Reomte Control Interface - NeometrixStandard Reomte Control Interface - Neometrix
Standard Reomte Control Interface - Neometrix
 
ethical hacking-mobile hacking methods.ppt
ethical hacking-mobile hacking methods.pptethical hacking-mobile hacking methods.ppt
ethical hacking-mobile hacking methods.ppt
 
Top 10 Oil and Gas Projects in Saudi Arabia 2024.pdf
Top 10 Oil and Gas Projects in Saudi Arabia 2024.pdfTop 10 Oil and Gas Projects in Saudi Arabia 2024.pdf
Top 10 Oil and Gas Projects in Saudi Arabia 2024.pdf
 
power quality voltage fluctuation UNIT - I.pptx
power quality voltage fluctuation UNIT - I.pptxpower quality voltage fluctuation UNIT - I.pptx
power quality voltage fluctuation UNIT - I.pptx
 
Hierarchical Digital Twin of a Naval Power System
Hierarchical Digital Twin of a Naval Power SystemHierarchical Digital Twin of a Naval Power System
Hierarchical Digital Twin of a Naval Power System
 
block diagram and signal flow graph representation
block diagram and signal flow graph representationblock diagram and signal flow graph representation
block diagram and signal flow graph representation
 
RAT: Retrieval Augmented Thoughts Elicit Context-Aware Reasoning in Long-Hori...
RAT: Retrieval Augmented Thoughts Elicit Context-Aware Reasoning in Long-Hori...RAT: Retrieval Augmented Thoughts Elicit Context-Aware Reasoning in Long-Hori...
RAT: Retrieval Augmented Thoughts Elicit Context-Aware Reasoning in Long-Hori...
 
ethical hacking in wireless-hacking1.ppt
ethical hacking in wireless-hacking1.pptethical hacking in wireless-hacking1.ppt
ethical hacking in wireless-hacking1.ppt
 
AP LAB PPT.pdf ap lab ppt no title specific
AP LAB PPT.pdf ap lab ppt no title specificAP LAB PPT.pdf ap lab ppt no title specific
AP LAB PPT.pdf ap lab ppt no title specific
 
一比一原版(SFU毕业证)西蒙菲莎大学毕业证成绩单如何办理
一比一原版(SFU毕业证)西蒙菲莎大学毕业证成绩单如何办理一比一原版(SFU毕业证)西蒙菲莎大学毕业证成绩单如何办理
一比一原版(SFU毕业证)西蒙菲莎大学毕业证成绩单如何办理
 
AKS UNIVERSITY Satna Final Year Project By OM Hardaha.pdf
AKS UNIVERSITY Satna Final Year Project By OM Hardaha.pdfAKS UNIVERSITY Satna Final Year Project By OM Hardaha.pdf
AKS UNIVERSITY Satna Final Year Project By OM Hardaha.pdf
 
NO1 Uk best vashikaran specialist in delhi vashikaran baba near me online vas...
NO1 Uk best vashikaran specialist in delhi vashikaran baba near me online vas...NO1 Uk best vashikaran specialist in delhi vashikaran baba near me online vas...
NO1 Uk best vashikaran specialist in delhi vashikaran baba near me online vas...
 
H.Seo, ICLR 2024, MLILAB, KAIST AI.pdf
H.Seo,  ICLR 2024, MLILAB,  KAIST AI.pdfH.Seo,  ICLR 2024, MLILAB,  KAIST AI.pdf
H.Seo, ICLR 2024, MLILAB, KAIST AI.pdf
 
Sachpazis:Terzaghi Bearing Capacity Estimation in simple terms with Calculati...
Sachpazis:Terzaghi Bearing Capacity Estimation in simple terms with Calculati...Sachpazis:Terzaghi Bearing Capacity Estimation in simple terms with Calculati...
Sachpazis:Terzaghi Bearing Capacity Estimation in simple terms with Calculati...
 
在线办理(ANU毕业证书)澳洲国立大学毕业证录取通知书一模一样
在线办理(ANU毕业证书)澳洲国立大学毕业证录取通知书一模一样在线办理(ANU毕业证书)澳洲国立大学毕业证录取通知书一模一样
在线办理(ANU毕业证书)澳洲国立大学毕业证录取通知书一模一样
 

NumberSystemsAnnotated.pdf

  • 2. Today's Topics  The significance of the bit and powers of 2  Data quantities (B, kB, MB, GB, etc)  Number systems (decimal, binary, octal , hexadecimal)  Representing negative numbers (sign-magnitude, 1’s complement, 2’s complement)  Binary addition (carries, overflows)  Binary subtraction
  • 4. The Significance of the Bit  A bit (Binary digIT) is merely 0 or 1  It is a unit of information since you cannot communicate with anything less than two states  The use of binary encoding dates back to the 1600s with Jacquard's loom, which created textiles using card templates with holes that allowed needles through
  • 5. Bits and Computers  The nice thing about a bit is that, with only two states, it is easy to embody in physical machinery  Each bit is simply a switch and computers moved from vacuum tubes to transistors for this e-
  • 6. Decimal Number System  Most computers count in binary, which we can easily understand from the decimal so ingrained in us 35462
  • 7. Decimal Number System  Most computers count in binary, which we can easily understand from the decimal so ingrained in us 35462 2x100
  • 8. Decimal Number System  Most computers count in binary, which we can easily understand from the decimal so ingrained in us 35462 2x100 6x101 +
  • 9. Decimal Number System  Most computers count in binary, which we can easily understand from the decimal so ingrained in us 35462 2x100 6x101 + 4x102 +
  • 10. Decimal Number System  Most computers count in binary, which we can easily understand from the decimal so ingrained in us 35462 2x100 6x101 + 4x102 + 5x103 +
  • 11. Decimal Number System  Most computers count in binary, which we can easily understand from the decimal so ingrained in us 35462 2x100 6x101 + 4x102 + 5x103 + 3x104 +
  • 12. Binary  Binary is exactly the same, only instead of ten digits/states (0 to 9) we have just two, so the base becomes 2: 10110 0x20 1x21 + 1x22 + 0x23 + 1x24 +
  • 13. Binary  Binary is exactly the same, only instead of ten digits/states (0 to 9) we have just two, so the base becomes 2: 10110b = 22d 0x20 1x21 + 1x22 + 0x23 + 1x24 +
  • 14. Binary  Binary is exactly the same, only instead of ten digits/states (0 to 9) we have just two, so the base becomes 2: 10110b = 22d 0x20 1x21 + 1x22 + 0x23 + 1x24 + Most Significant Bit (MSB) Least Significant Bit (LSB)
  • 15. Works for Fractional Numbers too... 35.462 2x10-3 6x10-2 + 4x10-1 + 5x100 + 3x101 +
  • 16. Works for Fractional Numbers too... 10.110b = 2.75d 0x2-3 1x2-2 + 1x2-1 + 0x20 + 1x21 + 35.462 2x10-3 6x10-2 + 4x10-1 + 5x100 + 3x101 +
  • 19. Representable Numbers  With d decimal digits, we can represent 10d different values, usually the numbers 0 to (10d -1) inclusive  In binary with n bits this becomes 2n values, usually the range 0 to (2n -1)  Computers usually assign a set number of bits (physical switches) to an instance of a type.  An integer is often 32 bits, so can represent positive integers from 0 to 4,294,967,295 incl.  Or a range of negative and positive integers...
  • 20. Other Common Bases  Higher bases make for shorter numbers that are easier for humans to manipulate. e.g. 6654733d =11001011000101100001101b  We traditionally choose powers-of-2 bases because this corresponds to whole chunks of binary
  • 21. Other Common Bases  Higher bases make for shorter numbers that are easier for humans to manipulate. e.g. 6654733d =11001011000101100001101b  We traditionally choose powers-of-2 bases because this corresponds to whole chunks of binary  Octal is base-8 (8=23 digits, which means 3 bits per digit)  6654733d =011-001-011-000-101-100-001-101b = 31305415o
  • 22. Other Common Bases  Higher bases make for shorter numbers that are easier for humans to manipulate. e.g. 6654733d =11001011000101100001101b  We traditionally choose powers-of-2 bases because this corresponds to whole chunks of binary  Octal is base-8 (8=23 digits, which means 3 bits per digit)  6654733d =011-001-011-000-101-100-001-101b = 31305415o  Hexadecimal is base-16 (16=24 digits so 4 bits per digit)  Our ten decimal digits aren't enough, so we add 6 new ones: 0,1,2,3,4,5,6,7,8,9,A,B,C,D,E,F  6654733d =0110-0101-1000-1011-0000-1101b =658B0Dh
  • 23. Other Common Bases  Higher bases make for shorter numbers that are easier for humans to manipulate. e.g. 6654733d =11001011000101100001101b  We traditionally choose powers-of-2 bases because this corresponds to whole chunks of binary  Octal is base-8 (8=23 digits, which means 3 bits per digit)  6654733d =011-001-011-000-101-100-001-101b = 31305415o  Hexadecimal is base-16 (16=24 digits so 4 bits per digit)  Our ten decimal digits aren't enough, so we add 6 new ones: 0,1,2,3,4,5,6,7,8,9,A,B,C,D,E,F  6654733d =0110-0101-1000-1011-0000-1101b =658B0Dh  Because we constantly slip between binary and hex, we have a special marker for it  Prefix with '0x' (zero-x). So 0x658B0D=6654733d , 0x123=291d
  • 24. Bytes  A byte was traditionally the number of bits needed to store a character of text  A de-facto standard of 8 bits has now emerged  256 values  0 to 255 incl.  Two hex digits to describe  0x00=0, 0xFF=255  Check: what does 0xBD represent?
  • 25. Bytes  A byte was traditionally the number of bits needed to store a character of text  A de-facto standard of 8 bits has now emerged  256 values  0 to 255 incl.  Two hex digits to describe  0x00=0, 0xFF=255  Check: what does 0xBD represent?  B → 11 or 1011  D → 13 or 1101  Result is 11x161 +13x160 = 189 or 10111101
  • 26. Larger Units  Strictly the SI units since 1998 are:  Kibibyte (KiB)  1024 bytes (closest power of 2 to 1000)  Mebibyte (MiB)  1,048,576 bytes  Gibibyte (GiB)  1,073,741,824 bytes
  • 27. Larger Units  Strictly the SI units since 1998 are:  Kibibyte (KiB)  1024 bytes (closest power of 2 to 1000)  Mebibyte (MiB)  1,048,576 bytes  Gibibyte (GiB)  1,073,741,824 bytes  but these haven't really caught on so we tend to still use the SI Kilobyte, Megabyte, Gigabyte. This leads to lots of confusion since technically these are multiples of 1,000.
  • 29. Unsigned Integer Addition  Addition of unsigned integers works the same way as addition of decimal (only simpler!)  0 + 0 = 0  0 + 1 = 1  1 + 0 = 1  1 + 1 = 0, carry 1  Only issue is that computers have fixed sized types so we can't go on adding forever... 111 + 001 001 + 001 Carry flag: Carry flag:
  • 30. Modulo or Clock Arithmetic  Overflow takes us across the dotted boundary  So 7+1=0 (overflow)  We say this is (7+1) mod 8 000 001 010 011 100 101 110 111 000 001 010 011 100 101 110 111
  • 31. Negative Numbers  All of this skipped over the need to represent negatives.  The naïve choice is to use the MSB to indicate +/-  1 in the MSB → negative  0 in the MSB → positive  This is the sign-magnitude technique -7 = 1111 Negative Normal positive representation of 7
  • 32. Difficulties with Sign-Magnitude  Has a representation of minus zero (10002 =-0) so wastes one of our 2n labels  Addition/subtraction circuitry must be designed from scratch 1101 + 0001 1110 Our unsigned addition alg.
  • 33. Difficulties with Sign-Magnitude  Has a representation of minus zero (10002 =-0) so wastes one of our 2n labels  Addition/subtraction circuitry must be designed from scratch 1101 + 0001 1110 Our unsigned addition alg. +13 +1 +14 Unsigned interpretation
  • 34. Difficulties with Sign-Magnitude  Has a representation of minus zero (10002 =-0) so wastes one of our 2n labels  Addition/subtraction circuitry must be designed from scratch 1101 + 0001 1110 -5 +1 -6 +13 +1 +14 Sign-mag interpretation Unsigned interpretation Our unsigned addition alg.
  • 35. Alternatively...  Gives us two discontinuities and a reversal of direction using normal addition circuitry!! 000 001 010 011 100 101 110 111 000 001 010 011 100 101 110 111
  • 36. Ones' Complement  The negative is the positive with all the bits flipped  7 → 0111 so -7 → 1000  Still the MSB is the sign  One discontinuity but still -0 :-( 000 001 010 011 100 101 110 111 000 001 010 011 100 101 110 111
  • 37. Two's Complement  The negative is the positive with all the bits flipped and 1 added (the same procedure for the inverse)  7 → 0111 so -7 → 1000+0001 → 1001  Still the MSB is the sign  One discontinuity and proper ordering 000 001 010 011 100 101 110 111 000 001 010 011 100 101 110 111
  • 38. Two's Complement  Positive to negative: Invert all the bits and add 1  Negative to positive: Same procedure!! 1011 (-5) → 0100 → 0101 (+5) 0101 (+5) → 1010 → 1011 (-5)
  • 39. Signed Addition 1101 +0001 1110 Our unsigned addition alg.  ...it just works with our addition algorithm! +13 +1 +14 Unsigned
  • 40. Signed Addition 1101 +0001 1110 -3 +1 -2 +13 +1 +14 2's-comp Unsigned Our unsigned addition alg.  ...it just works with our addition algorithm!
  • 41. Signed Addition 1101 +0001 1110 -3 +1 -2 +13 +1 +14 2's-comp Unsigned Our unsigned addition alg.  ...it just works with our addition algorithm!
  • 42.  So we can use the same circuitry for unsigned and 2s- complement addition :-)  Well, almost. Signed Addition 0100 +0100 1000 +4 +4 +8 Unsigned Carry flag: 0
  • 43.  So we can use the same circuitry for unsigned and 2s- complement addition :-)  Well, almost.  The problem is our MSB is now signifying the sign and our carry should really be testing the bit to its right :-( Signed Addition 0100 +0100 1000 +4 +4 -8 +4 +4 +8 2's-comp Unsigned Carry flag: 0
  • 44.  So we can use the same circuitry for unsigned and 2s- complement addition :-)  Well, almost.  The problem is our MSB is now signifying the sign and our carry should really be testing the bit to its right :-(  So we introduce an overflow flag that indicates this problem Signed Addition 0100 +0100 1000 +4 +4 -8 +4 +4 +8 2's-comp Unsigned Carry flag: 0 Overflow: 1
  • 45. Integer subtraction  Could implement the “borrowing” algorithm you probably learnt in school  But why bother? We can just add the 2's complement instead. 0100 - 0011 0100 +1101 0001 →
  • 46. Flags Summary  When adding/subtracting  Carry flag → overflow for unsigned integer  Overflow flag → overflow for signed integer  The CPU does not care whether it's handling signed or unsigned integers  Down to our compilers/programs to interpret the result
  • 47. Fractional Numbers  Scientific apps rarely survive on integers alone, but representing fractional parts efficiently is complicated.  Option one: fixed point  Set the point at a known location. Anything to the left represents the integer part; anything to the right the fractional part  But where do we set it??  Option two: floating point  Let the point 'float' to give more capacity on its left or right as needed  Much more efficient, but harder to work with  Very important: more in Numerical Methods course