SlideShare a Scribd company logo
1 of 51
Chapter 2 - Data Types
Today… ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Concepts to Learn… ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
What are Decimal Numbers? ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],Digital Binary System
What are Binary Numbers? ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],Digital Binary System
Binary Digital System ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],Digital Binary System
Electronic Representation of a Bit ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],Digital Binary System
The Power of the Bit… ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],Digital Binary System
Binary Nomenclature ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],Digital Binary System
What Kinds of Data? ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],Data Types
Some Important Data Types ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],Data Types
Unsigned Integers ,[object Object],3x100 + 2x10 + 9x1 = 329 1x4 + 0x2 + 1x1 = 5 0000 0110 1111 1010 0001 1000 0111 1100 1011 1001 ,[object Object],[object Object],Data Types 329 10 2 10 1 10 0 101 2 2 2 1 2 0 most significant least significant
Unsigned Integers  (continued…) Data Types 7 1 1 1 6 0 1 1 5 1 0 1 4 0 0 1 3 1 1 0 2 0 1 0 1 1 0 0 0 0 0 0 2 0 2 1 2 2
Unsigned Binary Arithmetic ,[object Object],[object Object],10010 10010 1111 + 1001   + 1011 + 1 11011 11101 10000 10111 + 111 Subtraction, multiplication, division,… 0 1 1 1 1 Data Types carry
Signed Integers ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],Data Types
Sign-Magnitude Integers ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],The left-bit encodes the sign: 0  =  + 1  =   Data Types
1’s Complement Integers ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],To negate a number, Invert it, bit-by-bit. The left-bit still encodes the sign: 0  =  + 1  =   Data Types
2’s Complement ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],Data Types
2’s Complement  (continued…) ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],Data Types
2’s Complement  (continued…) ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],00101 (5) 01001 (9) 11010 (1’s comp) (1’s comp) + 1 + 1 11011 (-5) (-9) 10110 10111 Data Types
2’s Complement  (continued…) ,[object Object],[object Object],[object Object],[object Object],0110 = 2 2  + 2 1  = 6 1110 = -2 3  + 2 2  + 2 1  = -2 0000 0110 1111 1010 0001 1000 0111 1100 1011 1001 Data Types
2’s Complement Shortcut ,[object Object],[object Object],[object Object],011010000 011010000 100101111 (1’s comp) + 1 100110000 100110000 (copy) (flip) Data Types
2’s Complement Negation ,[object Object],6  1010 7  1001 0  0000 -1  0001 4  1100 -8  1000  (??) Data Types
Quiz 00100110 (unsigned int) + 10001101  (signed magnitude)   + 11111101  (1’s complement)   + 00001101  (2’s complement)   + 10111101  (2’s complement)   (decimal)
Quiz 00100110 (unsigned int) + 10001101 (signed magnitude) (unsigned int) + 11111101 (1’s complement) (signed int) + 00001101 (2’s complement) (2’s complement) + 10111101 (2’s complement) Decimal 00011001 00010111 00100100   -31 11100001  (2’s complement) 11100000  (1’s complement) 10011111  (signed magnitude)   38 + -13   25 +  -2   23 +  13   36 + -67 -31
[object Object],Decimal to Binary Conversion 1     2 5  + 0     2 4  + 1     2 3  + 0     2 2  + 1     2 1  + 1     2 0  32  +  0  +  8  +  0  +  2  +  1 =  43 43 ,[object Object],Conversions 2 2 2 2 2 2 5  R 0 0  2  R 1 1  21  R 1 1  10  R 1 1  1  R 0 0  0  R 1 1
Decimal to Binary Conversion 0101 0110 01111011 00100011 11011101 01111101111 Conversions
Sign-Extension in 2’s Complement ,[object Object],0110 = 000000000000000110 =  1111 =  11111111111111111 =  1 =  6 6 -1 -1 -1 ,[object Object],Conversions
Word Sizes ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],Conversions
Rules of Binary Addition ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],Binary Arithmetic 5 + (-3) = 2  0000 0101 =  +5 + 1111 1101 =  -3 ---------  -- 0000 0010  = +2
Adding 2’s Complement Integers ,[object Object],[object Object],c 00110 +00101 01011 b1 00110 -00101 00001 0110 +0101 1011 Hmmm.  6 + 5   -5.   Obviously something went wrong. This is a case of  overflow . You can tell there is a problem - a positive plus a positive  cannot  give a negative. Binary Arithmetic
Overflow Revisited ,[object Object],[object Object],[object Object],[object Object],[object Object],Overflow
Logical Operations on Bits A B  AND 0 0  0 0 1  0 1 0  0 1 1  1 A B  OR 0 0  0 0 1  1 1 0  1 1 1  1 A  NOT 0  1 1  0  a = 001100101 b = 110010100 a AND b = ? a  OR b = ? NOT a  = ? A XOR b = ?  a AND b = 000000100 a  = 001100101 b  = 110010100 a OR  b = 111110101 NOT a  = 110011010 A B  XOR 0 0  0 0 1  1 1 0  1 1 1  0 A XOR b = 111110001 Logical Operations
Examples of Logical Operations ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],11000101 AND 00001111 00000101 11000101 OR 00001111 11001111 NOT 11000101 00111010 Logical Operations
Floating Point Numbers ,[object Object],[object Object],[object Object],[object Object],s exponent mantissa 1 8 23 Floating Point
Floating Point Numbers ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],s exponent mantissa 1 8 23 Floating Point
Floating Point Numbers ,[object Object],Mantissa is to be interpreted as  1 .1 This is 2 0  + 2 -1   = 1 + 1/2 = 1.5 The final number is 1.5 x 2 1  = 3 0 10000000 10000000000000000000000 Floating Point Positive number Exponent is 128 which means the  real exponent is 1
Floating Point Numbers ,[object Object],The final number is -1.65625 x 2 2  = -6.625 1 10000001 10101000000000000000000 Floating Point Negative number Exponent is 129 which means the  real exponent is 2 Mantissa is to be interpreted as  1 .10101 This is 2 0  + 2 -1  + 2 -3  + 2 -5  = 1 + 1/2 + 1/8 + 1/32 = 1.65625
Hexadecimal Notation ,[object Object],[object Object],[object Object],0100 0111 1000 1111 = 0x478F 1101 1110 1010 1101 = 0xDEAD 1011 1110 1110 1111 = 0xBEEF 1010 0101 1010 0101 = 0xA5A5 Binary  Hex 0000  0 0001  1 0010  2 0011  3 0100  4 0101  5 0110  6 0111  7 1000  8 1001  9 1010  A 1011  B 1100  C 1101  D 1110  E 1111  F ,[object Object],[object Object],Hexadecimal 0x is a common prefix for writing numbers which means hexadecimal
Binary to Hex Conversion ,[object Object],[object Object],011101010001111010011010111 7 D 4 F 8 A 3 This is not a new machine representation, just a convenient way to write the number. Hexadecimal
Decimal to Hex Conversion ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],Hexadecimal
Decimal to Hex Examples 12 decimal   = 1100  = 0xc 21 decimal   = 0001 0101  = 0x15 55 decimal   = 0011 0111  = 0x37 256 decimal  = 0001 0000 0000 = 0x100 47 decimal   = 0010 1111  = 0x2f 3 decimal   = 0011  = 0x3 127 decimal   = 0111 1111  = 0x7f 1029 decimal  = 0100 0000 0101 = 0x405 Hexadecimal
ASCII Codes ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],ASCII Characters
ASCII Characters 0 1 2 3 4 5 6 7 8 9 a b c d e f 0  1  2  3  4  5  6  7  8-9  a-f More controls More symbols ASCII Characters DEL o _ O ? / US SI ~ n ^ N > . RS SO } m ] M = - GS CR | l L < , FS FF { k [ K ; + ESC VT z j Z J : * SUB LF y i Y I 9 ) EM HT x h X H 8 ( CAN BS w g W G 7 ‘ ETB BEL v f V F 6 & SYN ACK u e U E 5 % NAK ENQ t d T D 4 $ DC4 EOT s c S C 3 # DC3 ETX r b R B 2 “ DC2 STX q a Q A 1 ! DC1 SOH p ` P @ 0 SP DLE NUL
Properties of ASCII Code ,[object Object],[object Object],[object Object],[object Object],[object Object],ASCII Characters
Displaying Characters ASCII Characters 48 Decimal 58 Decimal 116 Decimal 53 Decimal
MSP430 Data Types ,[object Object],[object Object],[object Object],[object Object],[object Object],Data Types
Review: Representation ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],Review
Review: Numbers… 7 6 5 4 3 2 1 0 -1 -2 -3 -4 111 110 101 100 011 010 001 000 011 010 001 000, 100 101 110 111 011 010 001 000, 111 110 101 100 011 010 001 000 111 110 101 100 Un-signed Signed  Magnitude 1’s  Complement 2’s  Complement Range: 0 to 7 -3 to 3 -3 to 3 -4 to 3 Review
 
ASCII Characters ASCII Characters

More Related Content

What's hot (20)

Data Representation
Data RepresentationData Representation
Data Representation
 
Data representation
Data representationData representation
Data representation
 
Representation of Integers
Representation of IntegersRepresentation of Integers
Representation of Integers
 
[1] Data Representation
[1] Data Representation[1] Data Representation
[1] Data Representation
 
Data representation in computers
Data representation in computersData representation in computers
Data representation in computers
 
Binary number systems multiplication
Binary number systems multiplicationBinary number systems multiplication
Binary number systems multiplication
 
Binary operations
 Binary operations Binary operations
Binary operations
 
Number systems r002
Number systems  r002Number systems  r002
Number systems r002
 
IS 139 Lecture 4
IS 139 Lecture 4IS 139 Lecture 4
IS 139 Lecture 4
 
Binary number ppt
Binary number pptBinary number ppt
Binary number ppt
 
Lec 02 data representation part 1
Lec 02 data representation part 1Lec 02 data representation part 1
Lec 02 data representation part 1
 
Number systems and conversions
Number systems and conversionsNumber systems and conversions
Number systems and conversions
 
Codes r005
Codes  r005Codes  r005
Codes r005
 
Top schools in delhi ncr
Top schools in delhi ncrTop schools in delhi ncr
Top schools in delhi ncr
 
NUMBER SYSTEM
NUMBER SYSTEMNUMBER SYSTEM
NUMBER SYSTEM
 
Pp02
Pp02Pp02
Pp02
 
Number System
Number SystemNumber System
Number System
 
Binary addition
Binary additionBinary addition
Binary addition
 
Data representation
Data representationData representation
Data representation
 
Number system
Number systemNumber system
Number system
 

Viewers also liked

HKG15-405: Redundant zero/sign-extension elimination in GCC
HKG15-405: Redundant zero/sign-extension elimination in GCCHKG15-405: Redundant zero/sign-extension elimination in GCC
HKG15-405: Redundant zero/sign-extension elimination in GCCLinaro
 
Importance of research
Importance of researchImportance of research
Importance of researchSarah Innes
 
Importance of Research
Importance of ResearchImportance of Research
Importance of ResearchDianna Cuevas
 
Ethics in research
Ethics in researchEthics in research
Ethics in researchMira K Desai
 
Meaning and characteristics of research
Meaning and characteristics of researchMeaning and characteristics of research
Meaning and characteristics of researchjedliam
 
Review of Related Literature
Review of Related LiteratureReview of Related Literature
Review of Related LiteratureJasper Obico
 
Sampling Methods in Qualitative and Quantitative Research
Sampling Methods in Qualitative and Quantitative ResearchSampling Methods in Qualitative and Quantitative Research
Sampling Methods in Qualitative and Quantitative ResearchSam Ladner
 
Literature Review (Review of Related Literature - Research Methodology)
Literature Review (Review of Related Literature - Research Methodology)Literature Review (Review of Related Literature - Research Methodology)
Literature Review (Review of Related Literature - Research Methodology)Dilip Barad
 
Ethics in research ppt by jiya
Ethics in research ppt by jiyaEthics in research ppt by jiya
Ethics in research ppt by jiyapanthanalil
 
Research process
Research processResearch process
Research processaditi garg
 

Viewers also liked (14)

HKG15-405: Redundant zero/sign-extension elimination in GCC
HKG15-405: Redundant zero/sign-extension elimination in GCCHKG15-405: Redundant zero/sign-extension elimination in GCC
HKG15-405: Redundant zero/sign-extension elimination in GCC
 
05 multiply divide
05 multiply divide05 multiply divide
05 multiply divide
 
Research ethics
Research ethicsResearch ethics
Research ethics
 
Importance of research
Importance of researchImportance of research
Importance of research
 
Importance of Research
Importance of ResearchImportance of Research
Importance of Research
 
Introduction to Research Ethics
Introduction to Research EthicsIntroduction to Research Ethics
Introduction to Research Ethics
 
Ethics in research
Ethics in researchEthics in research
Ethics in research
 
Meaning and characteristics of research
Meaning and characteristics of researchMeaning and characteristics of research
Meaning and characteristics of research
 
Review of Related Literature
Review of Related LiteratureReview of Related Literature
Review of Related Literature
 
Sampling Methods in Qualitative and Quantitative Research
Sampling Methods in Qualitative and Quantitative ResearchSampling Methods in Qualitative and Quantitative Research
Sampling Methods in Qualitative and Quantitative Research
 
Literature Review (Review of Related Literature - Research Methodology)
Literature Review (Review of Related Literature - Research Methodology)Literature Review (Review of Related Literature - Research Methodology)
Literature Review (Review of Related Literature - Research Methodology)
 
Ethics in research ppt by jiya
Ethics in research ppt by jiyaEthics in research ppt by jiya
Ethics in research ppt by jiya
 
Research questions and research objectives
Research questions and research objectivesResearch questions and research objectives
Research questions and research objectives
 
Research process
Research processResearch process
Research process
 

Similar to Chapter 02 Data Types

Similar to Chapter 02 Data Types (20)

Alu1
Alu1Alu1
Alu1
 
Binaty Arithmetic and Binary coding schemes
Binaty Arithmetic and Binary coding schemesBinaty Arithmetic and Binary coding schemes
Binaty Arithmetic and Binary coding schemes
 
NumberSystemsAnnotated.pdf
NumberSystemsAnnotated.pdfNumberSystemsAnnotated.pdf
NumberSystemsAnnotated.pdf
 
Representation of Negative Numbers
Representation of Negative NumbersRepresentation of Negative Numbers
Representation of Negative Numbers
 
digitalelectronics.ppt
digitalelectronics.pptdigitalelectronics.ppt
digitalelectronics.ppt
 
Logic Design 2009
Logic Design 2009Logic Design 2009
Logic Design 2009
 
lec2_BinaryArithmetic.ppt
lec2_BinaryArithmetic.pptlec2_BinaryArithmetic.ppt
lec2_BinaryArithmetic.ppt
 
3.Fixed-Floating Point.ppt
3.Fixed-Floating Point.ppt3.Fixed-Floating Point.ppt
3.Fixed-Floating Point.ppt
 
08. Numeral Systems
08. Numeral Systems08. Numeral Systems
08. Numeral Systems
 
number system
number systemnumber system
number system
 
09 Arithmetic
09  Arithmetic09  Arithmetic
09 Arithmetic
 
ch2.pdf
ch2.pdfch2.pdf
ch2.pdf
 
Digital electronics
Digital electronicsDigital electronics
Digital electronics
 
binarycode.pptx
binarycode.pptxbinarycode.pptx
binarycode.pptx
 
Number system and codes
Number system and codesNumber system and codes
Number system and codes
 
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
 
2's complement
2's complement2's complement
2's complement
 
Binary arithmetic
Binary arithmeticBinary arithmetic
Binary arithmetic
 
Chapter 2_Number system (EEEg4302).pdf
Chapter 2_Number system (EEEg4302).pdfChapter 2_Number system (EEEg4302).pdf
Chapter 2_Number system (EEEg4302).pdf
 
Chapter two FHI.pptx
Chapter two FHI.pptxChapter two FHI.pptx
Chapter two FHI.pptx
 

Chapter 02 Data Types

  • 1. Chapter 2 - Data Types
  • 2.
  • 3.
  • 4.
  • 5.
  • 6.
  • 7.
  • 8.
  • 9.
  • 10.
  • 11.
  • 12.
  • 13. Unsigned Integers (continued…) Data Types 7 1 1 1 6 0 1 1 5 1 0 1 4 0 0 1 3 1 1 0 2 0 1 0 1 1 0 0 0 0 0 0 2 0 2 1 2 2
  • 14.
  • 15.
  • 16.
  • 17.
  • 18.
  • 19.
  • 20.
  • 21.
  • 22.
  • 23.
  • 24. Quiz 00100110 (unsigned int) + 10001101 (signed magnitude) + 11111101 (1’s complement) + 00001101 (2’s complement) + 10111101 (2’s complement) (decimal)
  • 25. Quiz 00100110 (unsigned int) + 10001101 (signed magnitude) (unsigned int) + 11111101 (1’s complement) (signed int) + 00001101 (2’s complement) (2’s complement) + 10111101 (2’s complement) Decimal 00011001 00010111 00100100 -31 11100001 (2’s complement) 11100000 (1’s complement) 10011111 (signed magnitude) 38 + -13 25 + -2 23 + 13 36 + -67 -31
  • 26.
  • 27. Decimal to Binary Conversion 0101 0110 01111011 00100011 11011101 01111101111 Conversions
  • 28.
  • 29.
  • 30.
  • 31.
  • 32.
  • 33. Logical Operations on Bits A B AND 0 0 0 0 1 0 1 0 0 1 1 1 A B OR 0 0 0 0 1 1 1 0 1 1 1 1 A NOT 0 1 1 0 a = 001100101 b = 110010100 a AND b = ? a OR b = ? NOT a = ? A XOR b = ? a AND b = 000000100 a = 001100101 b = 110010100 a OR b = 111110101 NOT a = 110011010 A B XOR 0 0 0 0 1 1 1 0 1 1 1 0 A XOR b = 111110001 Logical Operations
  • 34.
  • 35.
  • 36.
  • 37.
  • 38.
  • 39.
  • 40.
  • 41.
  • 42. Decimal to Hex Examples 12 decimal = 1100 = 0xc 21 decimal = 0001 0101 = 0x15 55 decimal = 0011 0111 = 0x37 256 decimal = 0001 0000 0000 = 0x100 47 decimal = 0010 1111 = 0x2f 3 decimal = 0011 = 0x3 127 decimal = 0111 1111 = 0x7f 1029 decimal = 0100 0000 0101 = 0x405 Hexadecimal
  • 43.
  • 44. ASCII Characters 0 1 2 3 4 5 6 7 8 9 a b c d e f 0 1 2 3 4 5 6 7 8-9 a-f More controls More symbols ASCII Characters DEL o _ O ? / US SI ~ n ^ N > . RS SO } m ] M = - GS CR | l L < , FS FF { k [ K ; + ESC VT z j Z J : * SUB LF y i Y I 9 ) EM HT x h X H 8 ( CAN BS w g W G 7 ‘ ETB BEL v f V F 6 & SYN ACK u e U E 5 % NAK ENQ t d T D 4 $ DC4 EOT s c S C 3 # DC3 ETX r b R B 2 “ DC2 STX q a Q A 1 ! DC1 SOH p ` P @ 0 SP DLE NUL
  • 45.
  • 46. Displaying Characters ASCII Characters 48 Decimal 58 Decimal 116 Decimal 53 Decimal
  • 47.
  • 48.
  • 49. Review: Numbers… 7 6 5 4 3 2 1 0 -1 -2 -3 -4 111 110 101 100 011 010 001 000 011 010 001 000, 100 101 110 111 011 010 001 000, 111 110 101 100 011 010 001 000 111 110 101 100 Un-signed Signed Magnitude 1’s Complement 2’s Complement Range: 0 to 7 -3 to 3 -3 to 3 -4 to 3 Review
  • 50.