SEF9 - 55 Programming Concepts Lesson 04 (Floating Point numbers are not exact)

This C++ program generates Floating Point (FP) Numbers and its decimal equivalent. It is to prove a point that the FP System cannot represent all the real numbers that exist. FP numbers are coarse grained, etc. And there are other things that can cause trouble with Floating Point (FP) numbers.

================================
Tutorial Learning points and Discussions
================================

(1) All calculations using floating point representation of real numbers are approximate, because real numbers cannot be exactly represented in floating point representations. The real numbers are rounded up or rounded down to their closest floating point representations.

(2) Floating point computations accumulate their approximation errors. We have to minimize computations by seeking the minimum number of mathematical operations needed to achieve the same computation, because each mathematical operation will introduce an approximation error.

(3) Think of the "Python programming” (Decimal data type) for obvious reasons of course. And even in python, to avoid errors in numerical computations, do not forget to do “Error Trappings”. There is no overflow using Decimal datatype in Python.

(4) Know exactly what you are doing, what you are calculating. Know what input ranges you intend to run in your program, trap anything outside these ranges. Know the intermediate calculated ranges that you are expecting for correct operations, again trap anything outside these expected ranges. Know the output results that you expect in your program, again trap anything outside these expected output ranges.

(5) Parallel computing allows many computations to be conducted simultaneously. It provides speedup, i.e. give results faster. However, the considerations are different between serial programs and parallel programs, and are to be handled differently.



--
WASSALAM
wruslan.hahaha

Attachments:
SEF-Example-Floating-Point-numbers-are-not-exact.pdf

Full Version with Microsoft Word Version and Attachments
Return to Software Engineering Fundamentals (SEF9MMUWRY)
Previous Topic: 54 About software testing, software errors, testing documents
Next Topic: 56 Programming Concepts Lesson 05 (Avoiding overflow using Python Decimal datatype)

0 comments:

Post a Comment