Practical Numerical Methods in Physics and Astronomy. Lecture 1 Intro & IEEE Variable Types and Arithmetic


 Anastasia Thompson
 8 months ago
 Views:
Transcription
1 Practical Numerical Methods in Physics and Astronomy Lecture 1 Intro & IEEE Variable Types and Arithmetic Pat Scott Department of Physics, McGill University January 16, 2013 Slides available from patscott
2 Housekeeping Variable types You should all have copies of the course info sheet. Some things to note: Format: half lectures by me, half by you Monday lecture times (1pm vs 1:30) Textbook Programming & Languages Assignments: 4, mainly during the first half of the course Assignment collaboration/copying policy Presentations: how they work, scheduling (please choose topic and slot by next lecture!) Assessment: no exam (hooray)
3 Housekeeping Variable types You should all have copies of the course info sheet. Some things to note: Format: half lectures by me, half by you Monday lecture times (1pm vs 1:30) Textbook Programming & Languages Assignments: 4, mainly during the first half of the course Assignment collaboration/copying policy Presentations: how they work, scheduling (please choose topic and slot by next lecture!) Assessment: no exam (hooray) Ask questions! (especially stupid ones)
4 Outline Variable types 1 Variable types 2 3
5 Outline Variable types 1 Variable types 2 3
6 logicals/booleans Single bit 0/1 = true/false integers multiple logicals, each corresponding to a power of 2 i.e. just natural numbers base 2 unsigned or signed (+1 sign bit) = 52 fixed point short (15+1bit binary strings) or long (31+1)
7 floating point inexact representation of R sign bit s, mantissa/significand M and exponent e number = ( 1) s M B e E (given base B and offset E) For this example B = 2, E = 129 single ( = 32bit), double ( = 64bit), extended/quadruple ( = 128bit) complex composite of two floatingpoint numbers plus some interaction terms The bible: What Every Computer Scientist Should Know About FloatingPoint Arithmetic Goldberg (1991) (available here)
8 strings/characters cat, dog, PHYS606, etc. each character is encoded by some set number of bits In standard ASCII, there are 7 bits encoding 2 7 = 128 characters (not all printable) a = 97 (dec) = 61 (Hex) = (bin) pointers Integer memory addresses used to refer to other variables, functions, subroutines, pointers, objects, etc arrays, structures, classes, objects, etc Just bundles of other variables, often with additional operations defined on them
9 Limitations Variable types Overflows Above the representable range for number Integers tend to wrap around (or throw errors) Floats go to ±Inf Underflows Only an issue for floats number ±0 NaNs Not a Number Only really exists in floatingpoint specification Most often (at least in my lousy code) results from 1 a divide by 0 2 operations on ±Inf 3 imaginary results for real functions
10 Outline Variable types 1 Variable types 2 3
11 Floatingpoint Multiplication & Division A B 1 XOR (multiply) the sign bit 2 integer add/subtract the exponents 3 integer multiply/divide the mantissae Flush to zero 0 β e min β e + 1 min β e + 2 min β e + 3 min Gradual underflow 0 β e min β e + 1 min β e + 2 min β e + 3 min Going < smallest normalisable number in the rep. causes headaches subnormal/denormalised numbers are inaccurate and slow Rounding/representation error multiplies as floats are operated on always a problem, but magnified with denormalised numbers
12 Floatingpoint Addition and Subtraction A + B (when A > B) 1 shift B to the same exponent as A 2 integer add/subtract the mantissae B = 2, E = 129 again Two numbers are very different in size = the smaller is ignored There exists a smallest number that can be added/subtracted meaningfully from 1.0 machine accuracy Two numbers very similar size = subtraction causes cancellation errors Significant digits are lost, only those affected by roundoff remain
13 on integers Integer operations and arithmetic are fast and exact Well, except for division in this case the remainder is truncated there are other tricks to get quick rounded results Standard logical operations can be performed bitwise on whole integers at once This is good for: quick multiplication or division by 2 extracting/setting combinations of flags (booleans)
14 Outline Variable types 1 Variable types 2 3
15 Typing Variable types Languages can be strongly typed C, Fortran, many others = compatibility of variable types for each expression is checked at compiletime i.e. i n t e g e r : : mynum=3 character ( len =4) : : bird= " duck " mynum = 5!OK mynum = " 5 "! FAIL bird = mynum! FAIL or weakly typed e.g. Perl = type conversion happens automatically sometimes convenient, usually just dangerous Even stronglytyped languages can have implicit typing The golden rule: always declare variable types explicitly in your numerical codes!!!
16 Default widths Variable types Most new systems are 64bit Most scientific code was written on 32bit machines Variable widths can differ! Classic nasty bug: passing pointers between C and Fortran C pointer has same width as long int (32 bits) on 32bit, but twice the width on 64bit Fortran has no separate pointer type (attribute only) Linked CF90 code compiles fine on both machines Crashes with seg fault on 64bit machine, runs OK on 32bit = not enough space reserved for 64bit pointer in CF90 interface
17 Comparison using floatingpoint variables Never, ever write or i f ( myvar. eq. 0.d0 ) i f ( myvar1. eq. myvar2 ) Floating point numbers cannot be trusted to be exactly equal to anything!!! Much safer to write i f ( abs ( myvar ). lt. absprec ) or i f ( abs ( myvar1 / myvar2 1.d0 ). lt. relprec ) where absprec = Aɛ and relprec = Bɛ Floating point comparisons only OK to within some suitable multiple A, B >> 1 of ɛ!!! In practice A and B are set peralgorithm (according to roundoff error, speed, truncation error, etc)
18 Basic optimisation Write things in terms of + and, minimise / if possible i.e. (x+x+x) / (y*z) is faster than 3*x / y / z Multiplication is faster than exponentiation i.e. (x*x) is faster than x^2 at some stage the extra operations add up though; (x*x*x*x*x) is probably slower than x^5 Define any simple function inline if possible There are lots of other tricks modern compilers will do most of these things for you automatically, but you can usually help them out by thinking about minimising number and complexity of operations
19 Renormalisation of variables Avoid working with very big floats Speed  most CPUs are quicker doing double prec than extended prec Space  doubles take less space than extendeds (although nobody seems to care nowadays) Accuracy  it is easy to go beyond the max/min representable number Also avoid working with very small floats Speed  denormalised arithmetic is slooooow Space  as with big floats Accuracy  denormalised arithmetic is inaccurate Instead, choose a scale and renormalise A B A/A max Easier + faster to multiply by a scalefactor afterwards, even if that requires type conversion
20 Renormalisation of variables Consider working in log space if your data spans a huge range of scales, and you care about the small ones e.g. a range of 2 70 is way easier to work with than often a lot faster and more accurate; no huge or tiny floats Easier + faster to exponentiate afterwards, even if that requires type conversion
21 Next lecture: Monday Jan 21 Interpolation, especially cubic splines Assignment 1 is available now on the homepage Covers: Floating point issues & cubic spline interpolation Due in: Wednesday Jan 30 ( is fine)
Numerical Methods in Physics. Lecture 1 Intro & IEEE Variable Types and Arithmetic
Variable types Numerical Methods in Physics Lecture 1 Intro & IEEE Variable Types and Arithmetic Pat Scott Department of Physics, Imperial College November 1, 2016 Slides available from http://astro.ic.ac.uk/pscott/
More informationInf2C  Computer Systems Lecture 2 Data Representation
Inf2C  Computer Systems Lecture 2 Data Representation Boris Grot School of Informatics University of Edinburgh Last lecture Moore s law Types of computer systems Computer components Computer system stack
More informationModule 2: Computer Arithmetic
Module 2: Computer Arithmetic 1 B O O K : C O M P U T E R O R G A N I Z A T I O N A N D D E S I G N, 3 E D, D A V I D L. P A T T E R S O N A N D J O H N L. H A N N E S S Y, M O R G A N K A U F M A N N
More informationChapter 2 Float Point Arithmetic. Real Numbers in Decimal Notation. Real Numbers in Decimal Notation
Chapter 2 Float Point Arithmetic Topics IEEE Floating Point Standard Fractional Binary Numbers Rounding Floating Point Operations Mathematical properties Real Numbers in Decimal Notation Representation
More informationFloating Point Puzzles The course that gives CMU its Zip! Floating Point Jan 22, IEEE Floating Point. Fractional Binary Numbers.
class04.ppt 15213 The course that gives CMU its Zip! Topics Floating Point Jan 22, 2004 IEEE Floating Point Standard Rounding Floating Point Operations Mathematical properties Floating Point Puzzles For
More informationFloating Point Numbers
Floating Point Numbers Summer 8 Fractional numbers Fractional numbers fixed point Floating point numbers the IEEE 7 floating point standard Floating point operations Rounding modes CMPE Summer 8 Slides
More informationSystem Programming CISC 360. Floating Point September 16, 2008
System Programming CISC 360 Floating Point September 16, 2008 Topics IEEE Floating Point Standard Rounding Floating Point Operations Mathematical properties Powerpoint Lecture Notes for Computer Systems:
More informationData Representation Floating Point
Data Representation Floating Point CSCI 2400 / ECE 3217: Computer Architecture Instructor: David Ferry Slides adapted from Bryant & O Hallaron s slides via Jason Fritts Today: Floating Point Background:
More informationFloating point. Today! IEEE Floating Point Standard! Rounding! Floating Point Operations! Mathematical properties. Next time. !
Floating point Today! IEEE Floating Point Standard! Rounding! Floating Point Operations! Mathematical properties Next time! The machine model Chris Riesbeck, Fall 2011 Checkpoint IEEE Floating point Floating
More informationCharacters, Strings, and Floats
Characters, Strings, and Floats CS 350: Computer Organization & Assembler Language Programming 9/6: pp.8,9; 9/28: Activity Q.6 A. Why? We need to represent textual characters in addition to numbers. Floatingpoint
More informationWhat Every Programmer Should Know About FloatingPoint Arithmetic
What Every Programmer Should Know About FloatingPoint Arithmetic Last updated: October 15, 2015 Contents 1 Why don t my numbers add up? 3 2 Basic Answers 3 2.1 Why don t my numbers, like 0.1 + 0.2 add
More informationSystems I. Floating Point. Topics IEEE Floating Point Standard Rounding Floating Point Operations Mathematical properties
Systems I Floating Point Topics IEEE Floating Point Standard Rounding Floating Point Operations Mathematical properties IEEE Floating Point IEEE Standard 754 Established in 1985 as uniform standard for
More informationComputer Arithmetic Ch 8
Computer Arithmetic Ch 8 ALU Integer Representation Integer Arithmetic FloatingPoint Representation FloatingPoint Arithmetic 1 Arithmetic Logical Unit (ALU) (2) Does all work in CPU (aritmeettislooginen
More informationComputers and programming languages introduction
Computers and programming languages introduction Eugeniy E. Mikhailov The College of William & Mary Lecture 01 Eugeniy Mikhailov (W&M) Practical Computing Lecture 01 1 / 19 Class goals and structure Primary
More information8/30/2016. In Binary, We Have A Binary Point. ECE 120: Introduction to Computing. FixedPoint Representations Support Fractions
University of Illinois at UrbanaChampaign Dept. of Electrical and Computer Engineering ECE 120: Introduction to Computing Fixed and FloatingPoint Representations In Binary, We Have A Binary Point Let
More information4 Operations On Data 4.1. Foundations of Computer Science Cengage Learning
4 Operations On Data 4.1 Foundations of Computer Science Cengage Learning Objectives After studying this chapter, the student should be able to: List the three categories of operations performed on data.
More informationFloatingPoint Arithmetic
FloatingPoint Arithmetic ECS30 Winter 207 January 27, 207 Floating point numbers Floatingpoint representation of numbers (scientific notation) has four components, for example, 3.46 0 sign significand
More information15213 Recitation 2: Floating Point
15213 Recitation 2: Floating Point 1 Introduction This handout will introduce and test your knowledge of the floating point representation of real numbers, as defined by the IEEE standard. This information
More informationThe Design and Implementation of a Rigorous. A Rigorous High Precision Floating Point Arithmetic. for Taylor Models
The and of a Rigorous High Precision Floating Point Arithmetic for Taylor Models Department of Physics, Michigan State University East Lansing, MI, 48824 4th International Workshop on Taylor Methods Boca
More informationObjects and Types. COMS W1007 Introduction to Computer Science. Christopher Conway 29 May 2003
Objects and Types COMS W1007 Introduction to Computer Science Christopher Conway 29 May 2003 Java Programs A Java program contains at least one class definition. public class Hello { public static void
More informationCourse Schedule. CS 221 Computer Architecture. Week 3: Plan. I. Hexadecimals and Character Representations. Hexadecimal Representation
Course Schedule CS 221 Computer Architecture Week 3: Information Representation (2) Fall 2001 W1 Sep 11 Sep 14 Introduction W2 Sep 18 Sep 21 Information Representation (1) (Chapter 3) W3 Sep 25 Sep
More informationOn a 64bit CPU. Size/Range vary by CPU model and Word size.
On a 64bit CPU. Size/Range vary by CPU model and Word size. unsigned short x; //range 0 to 65553 signed short x; //range ± 32767 short x; //assumed signed There are (usually) no unsigned floats or doubles.
More informationFloating point. Today. IEEE Floating Point Standard Rounding Floating Point Operations Mathematical properties Next time.
Floating point Today IEEE Floating Point Standard Rounding Floating Point Operations Mathematical properties Next time The machine model Fabián E. Bustamante, Spring 2010 IEEE Floating point Floating point
More informationFloating Point Numbers. Lecture 9 CAP
Floating Point Numbers Lecture 9 CAP 3103 06162014 Review of Numbers Computers are made to deal with numbers What can we represent in N bits? 2 N things, and no more! They could be Unsigned integers:
More informationCS429: Computer Organization and Architecture
CS429: Computer Organization and Architecture Dr. Bill Young Department of Computer Sciences University of Texas at Austin Last updated: September 18, 2017 at 12:48 CS429 Slideset 4: 1 Topics of this Slideset
More informationFloating Point Arithmetic
Floating Point Arithmetic CS 365 FloatingPoint What can be represented in N bits? Unsigned 0 to 2 N 2s Complement 2 N1 to 2 N11 But, what about? very large numbers? 9,349,398,989,787,762,244,859,087,678
More information1. NUMBER SYSTEMS USED IN COMPUTING: THE BINARY NUMBER SYSTEM
1. NUMBER SYSTEMS USED IN COMPUTING: THE BINARY NUMBER SYSTEM 1.1 Introduction Given that digital logic and memory devices are based on two electrical states (on and off), it is natural to use a number
More information3.5 Floating Point: Overview
3.5 Floating Point: Overview Floating point (FP) numbers Scientific notation Decimal scientific notation Binary scientific notation IEEE 754 FP Standard Floating point representation inside a computer
More information4 Operations On Data 4.1. Foundations of Computer Science Cengage Learning
4 Operations On Data 4.1 Foundations of Computer Science Cengage Learning Objectives After studying this chapter, the student should be able to: List the three categories of operations performed on data.
More informationCOMP 122/L Lecture 2. Kyle Dewey
COMP 122/L Lecture 2 Kyle Dewey Outline Operations on binary values AND, OR, XOR, NOT Bit shifting (left, two forms of right) Addition Subtraction Twos complement Bitwise Operations Bitwise AND Similar
More information2 Computation with FloatingPoint Numbers
2 Computation with FloatingPoint Numbers 2.1 FloatingPoint Representation The notion of real numbers in mathematics is convenient for hand computations and formula manipulations. However, real numbers
More informationNumber Systems and Computer Arithmetic
Number Systems and Computer Arithmetic Counting to four billion two fingers at a time What do all those bits mean now? bits (011011011100010...01) instruction Rformat Iformat... integer data number text
More informationCS367 Test 1 Review Guide
CS367 Test 1 Review Guide This guide tries to revisit what topics we've covered, and also to briefly suggest/hint at types of questions that might show up on the test. Anything on slides, assigned reading,
More informationBut first, encode deck of cards. Integer Representation. Two possible representations. Two better representations WELLESLEY CS 240 9/8/15
Integer Representation Representation of integers: unsigned and signed Sign extension Arithmetic and shifting Casting But first, encode deck of cards. cards in suits How do we encode suits, face cards?
More informationIT 1204 Section 2.0. Data Representation and Arithmetic. 2009, University of Colombo School of Computing 1
IT 1204 Section 2.0 Data Representation and Arithmetic 2009, University of Colombo School of Computing 1 What is Analog and Digital The interpretation of an analog signal would correspond to a signal whose
More informationChapter 2. Instruction Set. RISC vs. CISC Instruction set. The University of Adelaide, School of Computer Science 18 September 2017
COMPUTER ORGANIZATION AND DESIGN The Hardware/Software Interface RISCV Edition Chapter 2 Instructions: Language of the Computer These slides are based on the slides by the authors. The slides doesn t
More informationCSCI 402: Computer Architectures. Arithmetic for Computers (4) Fengguang Song Department of Computer & Information Science IUPUI.
CSCI 402: Computer Architectures Arithmetic for Computers (4) Fengguang Song Department of Computer & Information Science IUPUI Homework 4 Assigned on Feb 22, Thursday Due Time: 11:59pm, March 5 on Monday
More informationCarnegie Mellon. Bryant and O Hallaron, Computer Systems: A Programmer s Perspective, Third Edition
Carnegie Mellon 1 Bits, Bytes and Integers Part 1 15213/18213/15513: Introduction to Computer Systems 2 nd Lecture, Aug. 31, 2017 Today s Instructor: Randy Bryant 2 Announcements Recitations are on
More informationCS321. Introduction to Numerical Methods
CS31 Introduction to Numerical Methods Lecture 1 Number Representations and Errors Professor Jun Zhang Department of Computer Science University of Kentucky Lexington, KY 40506 0633 August 5, 017 Number
More informationIndependent Representation
Independent Representation 1 Integer magnitude + 1 2 3 4 5 6 7 8 9 0 Float sign sign of exponent mantissa On standard 32 bit machines: INT_MAX = 2147483647 which gives 10 digits of precision, (i.e. the
More informationArithmetic Operations
Arithmetic Operations Arithmetic Operations addition subtraction multiplication division Each of these operations on the integer representations: unsigned two's complement 1 Addition One bit of binary
More informationFloatingPoint Numbers in Digital Computers
POLYTECHNIC UNIVERSITY Department of Computer and Information Science FloatingPoint Numbers in Digital Computers K. Ming Leung Abstract: We explain how floatingpoint numbers are represented and stored
More informationBits, Bytes, and Integers Part 2
Bits, Bytes, and Integers Part 2 15213: Introduction to Computer Systems 3 rd Lecture, Jan. 23, 2018 Instructors: Franz Franchetti, Seth Copen Goldstein, Brian Railing 1 First Assignment: Data Lab Due:
More informationAdministrivia. CMSC 216 Introduction to Computer Systems Lecture 24 Data Representation and Libraries. Representing characters DATA REPRESENTATION
Administrivia CMSC 216 Introduction to Computer Systems Lecture 24 Data Representation and Libraries Jan Plane & Alan Sussman {jplane, als}@cs.umd.edu Project 6 due next Friday, 12/10 public tests posted
More informationComputer arithmetics: integers, binary floatingpoint, and decimal floatingpoint
n!= 0 && n == n z+1 == z Computer arithmetics: integers, binary floatingpoint, and decimal floatingpoint v+ww!= v x+1 < x Peter Sestoft 20100216 y!= y p == n && 1/p!= 1/n 1 Computer arithmetics Computer
More informationCS101 Introduction to computing Floating Point Numbers
CS101 Introduction to computing Floating Point Numbers A. Sahu and S. V.Rao Dept of Comp. Sc. & Engg. Indian Institute of Technology Guwahati 1 Outline Need to floating point number Number representation
More informationNumber Systems. Binary Numbers. Appendix. Decimal notation represents numbers as powers of 10, for example
Appendix F Number Systems Binary Numbers Decimal notation represents numbers as powers of 10, for example 1729 1 103 7 102 2 101 9 100 decimal = + + + There is no particular reason for the choice of 10,
More informationLogic, Words, and Integers
Computer Science 52 Logic, Words, and Integers 1 Words and Data The basic unit of information in a computer is the bit; it is simply a quantity that takes one of two values, 0 or 1. A sequence of k bits
More informationBits, Bytes and Integers
Bits, Bytes and Integers Computer Systems Organization (Spring 2016) CSCIUA 201, Section 2 Instructor: Joanna Klukowska Slides adapted from Randal E. Bryant and David R. O Hallaron (CMU) Mohamed Zahran
More informationHardware Modules for Safe Integer and FloatingPoint Arithmetic
Hardware Modules for Safe Integer and FloatingPoint Arithmetic A Thesis submitted to the Graduate School Of The University of Cincinnati In partial fulfillment of the requirements for the degree of Master
More informationC NUMERIC FORMATS. Overview. IEEE SinglePrecision Floatingpoint Data Format. Figure C0. Table C0. Listing C0.
C NUMERIC FORMATS Figure C. Table C. Listing C. Overview The DSP supports the 32bit singleprecision floatingpoint data format defined in the IEEE Standard 754/854. In addition, the DSP supports an
More informationCS 265. Computer Architecture. Wei Lu, Ph.D., P.Eng.
CS 265 Computer Architecture Wei Lu, Ph.D., P.Eng. 1 Part 1: Data Representation Our goal: revisit and reestablish fundamental of mathematics for the computer architecture course Overview: what are bits
More informationScientific Computing. Error Analysis
ECE257 Numerical Methods and Scientific Computing Error Analysis Today s s class: Introduction to error analysis Approximations RoundOff Errors Introduction Error is the difference between the exact solution
More informationNumber Representation 3/2/01 Lecture #
Number Representation 3/2/01 Lecture #11 16.070 How are numbers represented in a computer? Data come in two basic types! Numbers Whole/Integer (1, 3, 0) Natural, Positive (1, 2, 3) Real/Floatingpoint
More informationICS Instructor: Aleksandar Kuzmanovic TA: Ionut Trestian Recitation 2
ICS 2008 Instructor: Aleksandar Kuzmanovic TA: Ionut Trestian Recitation 2 Data Representations Sizes of C Objects (in Bytes) C Data Type Compaq Alpha Typical 32bit Intel IA32 int 4 4 4 long int 8 4 4
More informationLecture 10. Floating point arithmetic GPUs in perspective
Lecture 10 Floating point arithmetic GPUs in perspective Announcements Interactive use on Forge Trestles accounts? A4 2012 Scott B. Baden /CSE 260/ Winter 2012 2 Today s lecture Floating point arithmetic
More informationIntroduction to Modern Fortran
Introduction to Modern Fortran p. 1/?? Introduction to Modern Fortran KIND, Precision and COMPLEX Nick Maclaren Computing Service nmm1@cam.ac.uk, ext. 34761 November 2007 Introduction to Modern Fortran
More informationComputer Organization CS 206 T Lec# 2: Instruction Sets
Computer Organization CS 206 T Lec# 2: Instruction Sets Topics What is an instruction set Elements of instruction Instruction Format Instruction types Types of operations Types of operand Addressing mode
More informationIBM 370 Basic Data Types
IBM 370 Basic Data Types This lecture discusses the basic data types used on the IBM 370, 1. Two s complement binary numbers 2. EBCDIC (Extended Binary Coded Decimal Interchange Code) 3. Zoned Decimal
More informationArithmetic and Bitwise Operations on Binary Data
Arithmetic and Bitwise Operations on Binary Data CSCI 224 / ECE 317: Computer Architecture Instructor: Prof. Jason Fritts Slides adapted from Bryant & O Hallaron s slides 1 Boolean Algebra Developed by
More informationThe Perils of Floating Point
The Perils of Floating Point by Bruce M. Bush Copyright (c) 1996 Lahey Computer Systems, Inc. Permission to copy is granted with acknowledgement of the source. Many great engineering and scientific advances
More information! Addition! Multiplication! Bigger Example  RSA cryptography
! Addition! Multiplication! Bigger Example  RSA cryptography Modular Arithmetic Modular Exponentiation Primality Testing (Fermat s little theorem) Probabilistic algorithm Euclid s Algorithm for gcd (greatest
More information1.2 Roundoff Errors and Computer Arithmetic
1.2 Roundoff Errors and Computer Arithmetic 1 In a computer model, a memory storage unit word is used to store a number. A word has only a finite number of bits. These facts imply: 1. Only a small set
More informationComputational Methods. Sources of Errors
Computational Methods Sources of Errors Manfred Huber 2011 1 Numerical Analysis / Scientific Computing Many problems in Science and Engineering can not be solved analytically on a computer Numeric solutions
More informationGPU Floating Point Features
CSE 591: GPU Programming Floating Point Considerations Klaus Mueller Computer Science Department Stony Brook University Objective To understand the fundamentals of floatingpoint representation To know
More informationLecture 6: Signed Numbers & Arithmetic Circuits. BCD (Binary Coded Decimal) Points Addressed in this Lecture
Points ddressed in this Lecture Lecture 6: Signed Numbers rithmetic Circuits Professor Peter Cheung Department of EEE, Imperial College London (Floyd 2.52.7, 6.16.7) (Tocci 6.16.11, 9.19.2, 9.4) Representing
More information10.1. Unit 10. Signed Representation Systems Binary Arithmetic
0. Unit 0 Signed Representation Systems Binary Arithmetic 0.2 BINARY REPRESENTATION SYSTEMS REVIEW 0.3 Interpreting Binary Strings Given a string of s and 0 s, you need to know the representation system
More information9/23/15. Agenda. Goals of this Lecture. For Your Amusement. Number Systems and Number Representation. The Binary Number System
For Your Amusement Number Systems and Number Representation Jennifer Rexford Question: Why do computer programmers confuse Christmas and Halloween? Answer: Because 25 Dec = 31 Oct  http://www.electronicsweekly.com
More informationThe Sign consists of a single bit. If this bit is '1', then the number is negative. If this bit is '0', then the number is positive.
IEEE 754 Standard  Overview Frozen Content Modified by on 13Sep2017 Before discussing the actual WB_FPU  Wishbone Floating Point Unit peripheral in detail, it is worth spending some time to look at
More informationPROGRAMMAZIONE I A.A. 2017/2018
PROGRAMMAZIONE I A.A. 2017/2018 TYPES TYPES Programs have to store and process different kinds of data, such as integers and floatingpoint numbers, in different ways. To this end, the compiler needs to
More informationNumerical Computing in C and C++ Jamie Griffin. Semester A 2017 Lecture 2
Numerical Computing in C and C++ Jamie Griffin Semester A 2017 Lecture 2 Visual Studio in QM PC rooms Microsoft Visual Studio Community 2015. Bancroft Building 1.15a; Queen s W207, EB7; Engineering W128.D.
More informationCS 107 Lecture 2: Bits and Bytes (continued)
CS 107 Lecture 2: Bits and Bytes (continued) Friday, January 12, 2018 Computer Systems Winter 2018 Stanford University Computer Science Department Reading: Reader: Number Formats Used in CS 107 and Bits
More informationCS101 Lecture 04: Binary Arithmetic
CS101 Lecture 04: Binary Arithmetic Binary Number Addition Two s complement encoding Briefly: real number representation Aaron Stevens (azs@bu.edu) 25 January 2013 What You ll Learn Today Counting in binary
More informationClasses of Real Numbers 1/2. The Real Line
Classes of Real Numbers All real numbers can be represented by a line: 1/2 π 1 0 1 2 3 4 real numbers The Real Line { integers rational numbers nonintegral fractions irrational numbers Rational numbers
More informationMore Programming Constructs  Introduction
More Programming Constructs  Introduction We can now examine some additional programming concepts and constructs Chapter 5 focuses on: internal data representation conversions between one data type and
More informationNumber Systems & Encoding
Number Systems & Encoding Lecturer: Sri Parameswaran Author: Hui Annie Guo Modified: Sri Parameswaran Week2 1 Lecture overview Basics of computing with digital systems Binary numbers Floating point numbers
More informationData Representation and Introduction to Visualization
Data Representation and Introduction to Visualization Massimo Ricotti ricotti@astro.umd.edu University of Maryland Data Representation and Introduction to Visualization p.1/18 VISUALIZATION Visualization
More informationCS1 Lecture 5 Jan. 26, 2018
CS1 Lecture 5 Jan. 26, 2018 HW1 due Monday, 9:00am. Notes: Do not write all the code at once (for Q1 and 2) before starting to test. Take tiny steps. Write a few lines test... add a line or two test...
More informationChapter 3 Arithmetic for Computers (Part 2)
Department of Electr rical Eng ineering, Chapter 3 Arithmetic for Computers (Part 2) 王振傑 (ChenChieh Wang) ccwang@mail.ee.ncku.edu.tw ncku edu Depar rtment of Electr rical Eng ineering, FengChia Unive
More informationDivisibility Rules and Their Explanations
Divisibility Rules and Their Explanations Increase Your Number Sense These divisibility rules apply to determining the divisibility of a positive integer (1, 2, 3, ) by another positive integer or 0 (although
More informationBits, Bytes and Integers Part 1
Bits, Bytes and Integers Part 1 15213/18213/15513: Introduction to Computer Systems 2 nd Lecture, Jan. 18, 2018 Instructors: Franz Franchetti Seth Copen Goldstein Brian Railing 1 Announcements Waitlist
More informationFloating Point. The World is Not Just Integers. Programming languages support numbers with fraction
1 Floating Point The World is Not Just Integers Programming languages support numbers with fraction Called floatingpoint numbers Examples: 3.14159265 (π) 2.71828 (e) 0.000000001 or 1.0 10 9 (seconds in
More informationHow Computers Handle Numbers
How Computers Handle Numbers p. 1/?? How Computers Handle Numbers Some of the Sordid Details Nick Maclaren July 2009 How Computers Handle Numbers p. 2/?? This Is Now Later Explanations of a few of the
More informationCS/COE 0447 Example Problems for Exam 2 Spring 2011
CS/COE 0447 Example Problems for Exam 2 Spring 2011 1) Show the steps to multiply the 4bit numbers 3 and 5 with the fast shiftadd multipler. Use the table below. List the multiplicand (M) and product
More informationFloatingpoint Arithmetic. where you sum up the integer to the left of the decimal point and the fraction to the right.
Floatingpoint Arithmetic Reading: pp. 312328 FloatingPoint Representation Nonscientific floating point numbers: A noninteger can be represented as: 2 4 2 3 2 2 2 1 2 0.21 22 23 24 where you sum
More informationInteger Representation
Integer Representation Representation of integers: unsigned and signed Modular arithmetic and overflow Sign extension Shifting and arithmetic Multiplication Casting 1 Fixed width integer encodings Unsigned
More informationFor instance, if B = 10000, the number is represented internally as [3456, 7890, 12].
NAME SYNOPSIS DESCRIPTION Math::BigInt::Calc  Pure Perl module to support Math::BigInt This library provides support for big integer calculations. It is not intended to be used by other modules. Other
More informationComputational Mathematics: Models, Methods and Analysis. Zhilin Li
Computational Mathematics: Models, Methods and Analysis Zhilin Li Chapter 1 Introduction Why is this course important (motivations)? What is the role of this class in the problem solving process using
More informationCS2630: Computer Organization Homework 1 Bits, bytes, and memory organization Due January 25, 2017, 11:59pm
CS2630: Computer Organization Homework 1 Bits, bytes, and memory organization Due January 25, 2017, 11:59pm Instructions: Show your work. Correct answers with no work will not receive full credit. Whether
More informationProgram Fundamentals
Program Fundamentals /* HelloWorld.java * The classic Hello, world! program */ class HelloWorld { public static void main (String[ ] args) { System.out.println( Hello, world! ); } } /* HelloWorld.java
More informationl l l l l l l Base 2; each digit is 0 or 1 l Each bit in place i has value 2 i l Binary representation is used in computers
198:211 Computer Architecture Topics: Lecture 8 (W5) Fall 2012 Data representation 2.1 and 2.2 of the book Floating point 2.4 of the book Computer Architecture What do computers do? Manipulate stored information
More informationCS 430 Spring Mike Lam, Professor. Data Types and Type Checking
CS 430 Spring 2015 Mike Lam, Professor Data Types and Type Checking Type Systems Type system Rules about valid types, type compatibility, and how data values can be used Benefits of a robust type system
More information2. Integers. 9 * celsius / Celsius to Fahrenheit. Precedence. (9 * celsius / 5) + 32
2. Integers Evaluation of Arithmetic Expressions, Associativity and Precedence, Arithmetic Operators, Domain of Types int, unsigned int 93 Celsius to Fahrenheit // Program: fahrenheit.cpp // Convert temperatures
More informationCS61C : Machine Structures
inst.eecs.berkeley.edu/~cs61c CS61C : Machine Structures Lecture #10 Instruction Representation II, Floating Point I 20051003 Lecturer PSOE, new dad Dan Garcia www.cs.berkeley.edu/~ddgarcia #9 bears
More information1010 2?= ?= CS 64 Lecture 2 Data Representation. Decimal Numbers: Base 10. Reading: FLD Digits: 0, 1, 2, 3, 4, 5, 6, 7, 8, 9
CS 64 Lecture 2 Data Representation Reading: FLD 1.21.4 Decimal Numbers: Base 10 Digits: 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 Example: 3271 = (3x10 3 ) + (2x10 2 ) + (7x10 1 ) + (1x10 0 ) 1010 10?= 1010 2?= 1
More informationFundamentals of Programming
Fundamentals of Programming Lecture 3  Constants, Variables, Data Types, And Operations Lecturer : Ebrahim Jahandar Borrowed from lecturer notes by Omid Jafarinezhad Outline C Program Data types Variables
More informationCSE A215 Assembly Language Programming for Engineers
CSE A215 Assembly Language Programming for Engineers Lecture 7 MIPS vs. ARM (COD Chapter 2 and Exam #1 Review) October 12, 2012 Sam Siewert Comparison of MIPS32 and ARM Instruction Formats and Addressing
More informationFloating Point. What can be represented in N bits? 0 to 2N1. 9,349,398,989,787,762,244,859,087, x 1067
MIPS Floating Point Operations Cptr280 Dr Curtis Nelson Floating Point What can be represented in N bits? Unsigned 2 s Complement 0 to 2N12N1 to 2N11 But, what about Very large numbers? 9,349,398,989,787,762,244,859,087,678
More informationLecture 4  Number Representations, DSK Hardware, Assembly Programming
Lecture 4  Number Representations, DSK Hardware, Assembly Programming James Barnes (James.Barnes@colostate.edu) Spring 2014 Colorado State University Dept of Electrical and Computer Engineering ECE423
More informationLecture Notes: FloatingPoint Numbers
Lecture Notes: FloatingPoint Numbers CS227Scientific Computing September 8, 2010 What this Lecture is About How computers represent numbers How this affects the accuracy of computation Positional Number
More information