Unit Conversions and Big Fractions: How We Keep Precision

Precision in numbers is crucial, yet not all modern solutions are built for it. Learn how Decipad gives you the tools to make numbers and units work together harmoniously, so your results are always accurate and reliable.

Share this

Introduction

When it comes to numerical computation, precision and unit compatibility are the name of the game. Introducing the Decipad language – an innovative solution, tailored for handling numbers with meticulous precision, while effortlessly managing various units. In this article, we'll delve into the world of Decipad, uncovering its strategy for conducting arithmetic operations with differing units, the significance of upholding precision, and the ingenious use of arbitrary-precision rationals to make it all happen.

Harmonizing Units and Number Crunching

Ever wondered how you could smoothly add up distances in miles and kilometres, hours and days, dollars per square foot and dollars per square meter? In a spreadsheet or any typical programming environment, you’d have to perform the conversion yourself. Regular programming languages might stumble here, but not Decipad.

Decipad smartly converts units from common language, making sure your numbers play well together. So, whether you're dealing with operations between miles and kilometres, Decipad makes the conversion for you. And when the math is over, it translates the result back into the unit you want, so it all makes perfect sense.

You can read more about units in our blog post, From 1 bitcoin to 1 euro. Why units matter.

The Precision Puzzle

In the universe of numbers, precision is like the North Star – it guides you with unwavering accuracy. Decipad grasps this importance and tackles it head-on using arbitrary-precision rationals. Unlike traditional floating-point numbers, which can occasionally introduce tiny errors that can compound, Decipad takes a different route. It represents numbers with customizable precision, ensuring that even after multiple operations, the accuracy remains steadfast.

Decipad does this by, behind the scenes, representing numbers in a rational way: each number has a numerator and a denominator, which are represented as big integers. Unlike JS native floating-point numbers, a big integer allows us to have many more bits representing both the numerator and the denominator of a rational number.

You can see this in action in Decipad versus a traditional programming language like JavaScript.

In JS, if you want to add 777.7 with 0.9555, you will get 778.6555000000001.

This is not a problem specific to JavaScript, but happens in all systems that use a floating point representation of numbers.

In Decipad, you get the correct answer. This is extremely useful for the auto-conversion we perform when we have operations that require the same unit as arguments.

Bottom Line

In an era where precise outcomes are paramount, Decipad provides the tools necessary for numbers and units to collaborate harmoniously, resulting in accurate and reliable mathematical conclusions.

The Decipad language shines a spotlight on precision and unit compatibility in the world of numerical computation. Through its strategy for seamlessly managing diverse units and embracing arbitrary-precision rationals, Decipad emerges as a solution dedicated to upholding accuracy during calculations.

Related reads