ECE 103 Engineering Programming Chapter 3 Numbers Herbert G. Mayer, PSU CS Status 6/19/2015 Initial content copied verbatim from ECE 103 material developed.

Slides:



Advertisements
Similar presentations
Introduction to Computer Systems and Software Lecture 2 of 2 Simon Coupland
Advertisements

Floating Point Numbers. CMPE12cGabriel Hugh Elkaim 2 Floating Point Numbers Registers for real numbers usually contain 32 or 64 bits, allowing 2 32 or.
Floating Point Numbers. CMPE12cCyrus Bazeghi 2 Floating Point Numbers Registers for real numbers usually contain 32 or 64 bits, allowing 2 32 or 2 64.
CS 151 Digital Systems Design Lecture 3 More Number Systems.
Chapter 5 Floating Point Numbers. Real Numbers l Floating point representation is used whenever the number to be represented is outside the range of integer.
Number Systems Standard positional representation of numbers:
M68K Assembly Language Programming Bob Britton Chapter 12 IEEE Floating Point Notice: Chapter slides in this series originally provided by B.Britton. This.
Floating Point Numbers
S. Barua – CPSC 240 CHAPTER 2 BITS, DATA TYPES, & OPERATIONS Topics to be covered are Number systems.
Computer Science 210 Computer Organization Floating Point Representation.
Syllabus Binary Numbers Number Conversion Decimal - Binary
Binary Number Systems.
Binary Representation and Computer Arithmetic
Simple Data Type Representation and conversion of numbers
ES 244: Digital Logic Design Chapter 1 Chapter 1: Introduction Uchechukwu Ofoegbu Temple University.
Data Representation – Binary Numbers
Computer Arithmetic Nizamettin AYDIN
Number Systems So far we have studied the following integer number systems in computer Unsigned numbers Sign/magnitude numbers Two’s complement numbers.
Computer Architecture
Data Representation and Computer Arithmetic
Binary, Decimal and Hexadecimal Numbers Svetlin Nakov Telerik Corporation
Chapter 3 Section 1 Number Representation Modern cryptographic methods, unlike the classical methods we just learned, are computer based. Representation.
S. Rawat I.I.T. Kanpur. Floating-point representation IEEE numbers are stored using a kind of scientific notation. ± mantissa * 2 exponent We can represent.
Oct. 18, 2007SYSC 2001* - Fall SYSC2001-Ch9.ppt1 See Stallings Chapter 9 Computer Arithmetic.
1 CS103 Guest Lecture Number Systems & Conversion Bitwise Logic Operations.
ECE 2110: Introduction to Digital Systems Signed Addition/Subtraction.
ITEC 1011 Introduction to Information Technologies 4. Floating Point Numbers Chapt. 5.
Integer & Floating Point Representations CDA 3101 Discussion Session 05.
COMP201 Computer Systems Floating Point Numbers. Floating Point Numbers  Representations considered so far have a limited range dependent on the number.
CSNB374: Microprocessor Systems Chapter 1: Introduction to Microprocessor.
CSPP58001 Floating Point Numbers. CSPP58001 Floating vs. fixed point Floating point refers to a binary decimal representation where there is not a fixed.
Number Systems & Operations
Floating Point in Binary 1.Place Value Chart:
Data Representation: Floating Point for Real Numbers Computer Organization and Assembly Language: Module 11.
Floating Point Numbers
Number Representation and Arithmetic Circuits
Number Systems and Computer Arithmetic Winter 2014 COMP 1380 Discrete Structures I Computing Science Thompson Rivers University.
ECE 103 Engineering Programming Chapter 4 Operators Herbert G. Mayer, PSU CS Status 6/19/2015 Initial content copied verbatim from ECE 103 material developed.
Fixed-point and floating-point numbers Ellen Spertus MCS 111 October 4, 2001.
Chapter 32 Binary Number System. Objectives After completing this chapter, you will be able to: –Describe the binary number system –Identify the place.
Binary Addition The simplest arithmetic operation in binary is addition. Adding two single-digit binary numbers is relatively simple, using a form of carrying:
1 CE 454 Computer Architecture Lecture 4 Ahmed Ezzat The Digital Logic, Ch-3.1.
Chapter 9 Computer Arithmetic
FLOATING-POINT NUMBER REPRESENTATION
CSCI206 - Computer Organization & Programming
Introduction To Computer Science
Number Systems and Binary Arithmetic
Data Representation Binary Numbers Binary Addition
CSE 102 Introduction to Computer Engineering
ECE 103 Engineering Programming Chapter 3 Numbers
William Stallings Computer Organization and Architecture 7th Edition
CS1010 Programming Methodology
Data Structures Mohammed Thajeel To the second year students
Chapter 2 Bits, Data Types & Operations Integer Representation
CSCI206 - Computer Organization & Programming
Number Representations
Data Representation in Computer Systems
ECEG-3202 Computer Architecture and Organization
Number Representation
Storing Integers and Fractions
ECE 103 Engineering Programming Chapter 8 Data Types and Constants
Number Representations
ECE 120 Midterm 1 HKN Review Session.
Presentation transcript:

ECE 103 Engineering Programming Chapter 3 Numbers Herbert G. Mayer, PSU CS Status 6/19/2015 Initial content copied verbatim from ECE 103 material developed by Professor Phillip PSU ECE

Syllabus What’s This Blue Code? Binary Numbers Number Conversion Decimal - Binary Bitwise Operations Logic Operations Other Base Representations Convert Decimal to Hex Positive and Negative Integers Floating Point Numbers

2 What’s This Blue Code? void foo( void ) { // foo } //end foo // <- implied return here int main( /* no params */ )// better main( void ) { // main foo(); return 0;// says: nothing went wrong! } //end main // learned about: Functions // similar to the printf() which you saw earlier

3 Binary Numbers Bit  Smallest unit of information (binary digit) A single bit has one of two distinct states:  0 (logical False, power close to 0 V  1 logical True, power close to defined + V A binary number consists of n bits grouped together. LSBMSB b n-1 b n-2 …b 1 b 0 = b n-1  2 n-1 + b n-2  2 n-2 + … + b 1  b 0  2 0

4 Binary Numbers Table 1: Given n bits, the number of possible states = 2 n n # States n n 0none101,024201,048, ,048212,097, ,096224,194, ,192238,388, , ,777, ,768:: ,536301,073,741, , ,147,483, , ,294,967, ,

5 Number Conversion Decimal - Binary Convert from binary to its equivalent base 10 value  Expand the powers of two Example: What is in decimal? = (1  2 3 ) + (1  2 2 ) + (1  2 1 ) + (0  2 0 ) = (1  8) + (1  4) + (1  2) + (0  1) = Convert from base 10 to its equivalent binary value  Successively divide by two; keep track of remainders Example: What is in binary? Base 10Remainder 14 / 2 = 70 7 / 2 = 31 3 / 2 = 11 1 / 2 = 01 Read the remainders backwards. Hence, =

6 Bitwise Operations ABA & B ABA | B ABA ^ B A~A Bitwise AND Bitwise OR Bitwise XOR Bitwise Complement ABA + BCarry Bitwise Addition

7 Logic Operations Logic operations are done one bit at a time (unary, AKA monadic) or a pair of bits (binary, AKA dyadic) Example: ~1011 = 0100Complement, unary 1010 & 1100 = 1000Bitwise AND, binary 1010 | 1100 = 1110Bitwise OR 1010 ^ 1100 = 0110Bitwise XOR

8 Other Base Representations Octal (base 8  0, …, 7) Hexadecimal (base 16  0, …, 9, A, B, C, D, E, F with F representing ) Table 2: 4-bit positive integer conversion table DecBinOctHexDecBinOctHex A B C D E F

9 Convert Binary to Hex Converting from binary to its equivalent hex: 1) Separate binary value into 4-bit groups 2) Replace each group by its hex value Example: = = AC44 16 Converting from hex to its equivalent binary: Replace each hex value by its 4-bit binary value. Example: = 6B13 16 =

10 Positive and Negative Integers Integers are exactly and easily representable in any integer base > 1, including base 2 Base 10Base 2Base 10Base Table 3: 4-bit positive only values 0 to 15 If only positive integers and zero are needed, then all of the bits in the binary representation are available to express the value. Given : n bits Range: 0 to 2 n – 1

11 For negative integers, the most significant bit (MSB) of the binary value is reserved as a sign bit Negative values are expressed as 2’s complement Table 4: 4-bit positive and negative values -8 to +7 Base 10Base 2 (2's comp) Base 10Base 2 (2's comp) If both positive and negative integers are needed, the maximum positive value is reduced by a factor of 2 Given : n bits Range: –2 n-1 to 2 n-1 – 1

12 Floating Point Numbers God created integers; Man invented floats Floating point is used to express real-valued numbers. There is an implicit base and decimal point Example: –634.9 Example: In scientific notation format (base 10) –6.349 × 10 2 mantissa signbase exponent

13 Binary can be used to represent floating point values, but usually only as an approximation IEEE 754 single-precision (32-bit) standard s e 1 e 2 …e 8 b 1 b 2 …b 23 8 bits Interpreted as unsigned integer e' 1 bit Sign 0 → + 1 → – 23 bits Interpreted as a base 2 value defined as m' = 0.b 1 b 2 …b 23 = b b …+ b if e' ≠ 0 then FP number = (-1) s × (1 + m') × 2 e'-127 if e' = 0 then FP number = (-1) s × m' ×

14 Example: IEEE 754 single precision (32-bit) The more bits available, the more precise the mantissa and the larger the exponent range e ' = s = 0m ' = = Number = (-1) s × (1 + m') × 2 e'-127 = × 2 45 ≈ × 10 13