Broader awareness of IEEE 754 limitations can be critical when developing and validating functionality.
One piece that is often overlooked is the limited significant digits that can cause confusion when numbers don't behave as expected. The number of significant digits is fixed and relates to the total amount of detail, not how large or small the number is:
// We can represent very large or small numbers// but precision is limited1.4327194e27// 1.4327194e+271.4327194e27===(1.4327194e27+1)// true// Large numbers don't reliably represent decimals90000000000000.11// 90000000000000.111000000000000000.11// 1000000000000000.12000000000000000.11// 2000000000000000// Precision loss doesn't line up with decimal numbers140737488355327.11// 140737488355327.11 140737488355328.11// 140737488355328.12// Precision loss can seem inconsistent14.073748835532711// 14.07374883553271214.073748835532811// 14.073748835532811
Much of the work comes down to understanding the realistic data for your application. If you are processing financial transactions you are unlikely to take an order of one quadrillion dollars less one cent, but if dealing with multiplication you can rapidly exceed the precision limits of the built in number format.
Christian, Coder, Creator...
I'm a full-stack web dev, I love JS; HTML and CSS are fun too.
I like to make API things with Node.js as well. I'm learning Python.
Feel free to message me! 👋
Yep. I've been working on a precise feels like calculation that takes data from temperature, humidity, pressure, and wind speed and give me a number — then I discovered that my number was inaccurate because, with this error in JS, and some rather important multiplication and exponents, my number got wacky very quickly.
Thankfully, there are JS libraries like Big.js and math.js to help solve these issues. 😅
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
Broader awareness of IEEE 754 limitations can be critical when developing and validating functionality.
One piece that is often overlooked is the limited significant digits that can cause confusion when numbers don't behave as expected. The number of significant digits is fixed and relates to the total amount of detail, not how large or small the number is:
Much of the work comes down to understanding the realistic data for your application. If you are processing financial transactions you are unlikely to take an order of one quadrillion dollars less one cent, but if dealing with multiplication you can rapidly exceed the precision limits of the built in number format.
Yep. I've been working on a precise
feels likecalculation that takes data from temperature, humidity, pressure, and wind speed and give me a number — then I discovered that my number was inaccurate because, with this error in JS, and some rather important multiplication and exponents, my number got wacky very quickly.Thankfully, there are JS libraries like
Big.jsandmath.jsto help solve these issues. 😅