are not used to represent currency due to rounding and accumulation errors. Python provides several primitives specifically develo

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
icon
Concept explainers
Question

2.19 LAB*: Program: Food receipt

 

Note: When accuracy is essential, floats are not used to represent currency due to rounding and accumulation errors. Python provides several primitives specifically developed to implement financial applications. However, these topics are beyond the scope of this lab.

Output each floating-point value with two digits after the decimal point, which can be achieved as follows:
print(f'{your_value:.2f}')

Expert Solution
Step 1

Summary
Floating-point arithmetic:
Mostly It is considered an esoteric topic. This is very surprising because floating point numbers are ubiquitous in computer systems. Almost all languages ​​have floating point data types. Computers from personal computers to supercomputers have floating-point accelerators. Most compilers are occasionally asked to compile floating-point algorithms. Also, almost all operating systems must respond to floating-point exceptions such as overflow. This white paper presents a tutorial on aspects of floating-point numbers that directly impact computer system designers.
Compressing an infinitely large number of real numbers into a finite number of bits requires an approximate representation. There are infinitely many integers, but most programs can store the results of integer arithmetic in 32 bits. In contrast, most computations involving real numbers given a fixed number of bits result in quantities that cannot be represented exactly with that many bits. Therefore, the result of a floating-point computation often has to be rounded to fit in its finite representation. This rounding error is characteristic of floating-point arithmetic. The Relative Error and Ulps section describe how it is measured.

Anyway, since most floating-point calculations have rounding errors, does it matter if basic arithmetic operations introduce more rounding errors than necessary? This question is the main topic of this section. . The Guard Digits section describes guard digits, a means of reducing error when subtracting two adjacent numbers. Guard digits were considered significant enough by IBM that in 1968 they were added to the double precision format of the System/360 architecture (single precision already had guard digits) and all existing digits in the field machine have been improved. Two examples are given to illustrate the usefulness of guard digits.

 

trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 2 steps with 2 images

Blurred answer
Knowledge Booster
Operators
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education