floating point operations
play

Floating-Point Operations Ali Taheri Sharif University of - PowerPoint PPT Presentation

Fu Fundamentals of Pr Programming (Py Python) Floating-Point Operations Ali Taheri Sharif University of Technology Spring 2019 Outline 1. Fixed-Point Representation 2. Floating-Point Representation 3. Arithmetic Errors 4. The math


  1. Fu Fundamentals of Pr Programming (Py Python) Floating-Point Operations Ali Taheri Sharif University of Technology Spring 2019

  2. Outline 1. Fixed-Point Representation 2. Floating-Point Representation 3. Arithmetic Errors 4. The math Module 2 Spring 2019 ALI TAHERI - FUNDAMENTALS OF PROGRAMMING [PYTHON]

  3. Fixed-Point The number of bits before and after the decimal point is fixed ◦ Example: 98.75 3 Spring 2019 ALI TAHERI - FUNDAMENTALS OF PROGRAMMING [PYTHON]

  4. Floating-Point Supports a trade-off between range and precision IEEE 754 Standard: 𝒕𝒋𝒉𝒐𝒋𝒈𝒋𝒅𝒃𝒐𝒆 ∗ 𝒄𝒃𝒕𝒇 𝒇𝒚𝒒𝒑𝒐𝒇𝒐𝒖 4 Spring 2019 ALI TAHERI - FUNDAMENTALS OF PROGRAMMING [PYTHON]

  5. Arithmetic Errors When dealing with floating-point numbers, the result of calculation may not be necessarily correct: 0.1 + 0.1 + 0.1 == 0.3 7/5 - 1 == 2/5 1 - 1/3 == 2/3 You should be careful when doing comparisons: abs(a-b) < 1e-4 5 Spring 2019 ALI TAHERI - FUNDAMENTALS OF PROGRAMMING [PYTHON]

  6. The math module Implements many of the IEEE functions for complex mathematical operations using floating point values, including logarithms and trigonometric operations. import math The import keyword enables us to include additional modules into our program 6 Spring 2019 ALI TAHERI - FUNDAMENTALS OF PROGRAMMING [PYTHON]

Download Presentation
Download Policy: The content available on the website is offered to you 'AS IS' for your personal information and use only. It cannot be commercialized, licensed, or distributed on other websites without prior consent from the author. To download a presentation, simply click this link. If you encounter any difficulties during the download process, it's possible that the publisher has removed the file from their server.

Recommend


More recommend