From 1 bitcoin to 1 euro. Units matter.

What good is a number without context?

Share this

Take the number 42. Apart from it being the meaning of life, it’s a pretty cool number. But, 42 euros or 42 km are two different quantities and 42 wei is an entirely different category. If you see a € or $ sign next to a number in modeling software, it's usually just formatting. And, if you are not paying attention, you can end up adding 42 euros to 42 wei without any sign of an error.

Today, most data programming tools don’t put a lot of focus on units. This is likely intentional. These tools were mostly designed for number crunching and less about knowledge sharing.

At Decipad, we are building a notebook to tell stories with data and numbers, so context is really important for what we are trying to achieve.

Why do we care about units?

Units can dramatically impact the accuracy of a model. They also give important context to numbers, especially when you are engaging with someone else’s work.

For example, a unit conversion caused trouble in Laufenburg, a town that straddles Germany and Switzerland. The two different countries calculated sea level in different ways. When two halves of a new bridge grew closer to one another, instead of being at the same height “above sea level”, one side was 54 cm higher than the other.

At Decipad, we believe units should not be an afterthought. So, we’ve spent a lot of time thinking about units, as we work on building a tool to make modeling more accessible.

How we’re making units easy to work with

We decided to make units part of our earliest prototypes and designed a type system that is aware of units (in layman terms this means that when your formulas are checked for errors, that includes unit errors). Our goal is to make units fast and easy to work with so they can be incorporated into any type of model from rocket science to making the perfect cup of coffee. Today, you can do a few cool things with units in Decipad.

1. Just write to express any unit.

Decipad is a low-code, notebook where you can write with text and numbers together. We’ve made it simple for units to be presented all the way through your models. All you need to do is write your desired units alongside your numbers. Like this,

Now, any calculations using MyIncome will always display results with the appropriate unit.

2. Convert units freely.

Designing a model is hard. Having the flexibility to explore and adapt to new circumstances is important. So, we’ve made it easy to play with units and convert them whenever you want; all while preventing mistakes.

If a conversion is impossible, Decipad will let you know.

If we don’t support a certain unit. You can define your own custom units and use a conversion to figure out proportions in an intuitive way. Let’s say we wanted to look at Hammer Weight in feathers:

If you’re working with mixed units, you can mix them at your will and conversions will always be automatic.

3. Minimize calculation errors.

I have to admit, I’m not very good at math. As a developer, I’ve come to improve over the years, but I still find it very challenging to design the right calculations. And, I’m always triple checking my results. Even in programming languages with type systems, I don’t get much help with the meaning of numbers, besides knowing whether the number is an integer or not.

With Decipad, this becomes really easy. I can write my equation and see if the units check out.

If I see the result contains the wrong unit, I easily know the division is wrong.

This way, Decipad guides me through calculations that were previously confusing and error prone. It can be hard to admit, but as humans we make a lot of mistakes.

Source: https://xkcd.com/604/

An example of one of those mistakes is attempting to add together two unrelated unit values.

In most modeling software and programming languages, the above calculation would result in a numerical output. It would be up to the user to identify the mistake. It’s really not a fun task to go through dozens of calculations and understand where things went wrong.

With Decipad, we designed a type system that is aware of units. In the example above, Area is not just a number, it's understood as meters ^ 2, or sqft. So, if used it incorrectly, you’ll understand straight away.

If you want to see an example of a model that shows this in action, click here.

The challenges ahead

We are excited about the potential this feature holds, but units haven’t been easy to implement, and we’re far from done.

1. We can’t convert everything.

One of the challenges that we face is that some conversions are half possible.

For instance, we can convert 12 months to a year, or a year into four quarters, but it’s impossible to convert a month into days, due to not all months having equal amounts of days.

2. Units could be even easier to specify.

We want to improve the user experience of annotating numbers with units. For now, Decipad allows for text based formulas. Up next, we are creating no-code, UI elements on top of this language to make modeling even easier. These UI elements will all need a great user experience for specifying units.

3. We can’t identify all the ways units are written.

How units are written greatly affects the ways Decipad can interpret them. For instance, people don’t use decimal notation when writing imperial units, writing 1’ 6” instead. Currently Decipad only understands if it is written 1.5ft.

The road ahead

There isn’t just one “number”, but an almost infinite amount of meanings that one number can have. In the future, we want Decipad to track context from raw numbers, through any calculation, and ensure it is displayed clearly in the process. If a mistake is made, we want to identify (or, even predict) what isn’t right and help you fix it easily.

This is just the beginning. If you are interested in geeking out on units, come say hi on Discord. We’d love to hear about your experience or challenges working with units.

— Fábio and the Decipad Team

Related reads