Skip to content

barbosacode-lab/floating-point-ieee754

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

The Floating Point System and the IEEE 754

IEEE 754 is a standard for normalizing so that the computer can represent real numbers from base-2 (binary). The binary system is used because it has a higher performance in dealing with calculations.

Principles and Fundamentals

✅ - This repository is for the authors own teaching purposes and is definitely not a blog post.

✅ - There is no lack of references on the Internet for understanding the problem.

✅ - Such that the goal is to experience these events as representation errors, precision, rounding, comparison and propagation. So that it is possible to understand in practice and implement alternatives.

✅ - The language chosen for the practical exercise was Javascript. But, the phenomenon happens in most programming languages and development environments.

The Numbers Dilemma 🤔♾

Given a range of values, we need to deal with the trade-off between representing as many values as possible and how to represent them accurately.

SinglePrecision and DoublePrecision From Wiki

  • The Double Precision system can store more values and with higher accuracy, since it has a higher capacity for significant digits (52 values) versus (23 vaulues) in single precision.

  • 5.25 in base-2

> +(5.25).toString(2)
output: 101.01

Representation Errors

  • Just as we cannot represent the fractional value (1/3) in the decimal base such that the value is (0.333333333...). In the binary system, it is no different. In some cases it is impossible to represent a number with 100% accuracy.

  • There is no such thing as infinite precision, since computer memory is finite.

  • One technique for representing fractional numbers in binary is to work with negative powers of an integer. In this way, it is possible to represent fractional quantities of an integer.

  • The use of binary numbers increases the performance of the computer when doing calculations. If there is a need for coverage because of the sensitivity of exact values in a '$FOO' application, this challenge is in the hands of the developer.

  • Since Javascript does not have a native decimal type like in Java (BigDecimal), a widely used alternative is to install libraries that can use a decimal of limited precision.

References and Inspirations, so far: ⏳

Feedback ⭐🚀

Learning in Public Method in the quest for better results. 📈

🔓 The fatest way to learn to the next level.

💌 If you have any feedback, please reach out to us at [email protected]

About

Hands-on Labs about Floating Point Arithmetic and more

Topics

Resources

License

Stars

Watchers

Forks