Table of Contents

Benefits Setup Usage

Automatic Unit Conversion

Lets do a practice problem:

How many days does it take for a 3.7V 500mAh battery to discharge when a 10kΩ resistor is placed across its terminals?

If we were to solve this using numeric datatypes, all unit conversions must be taken care of by hand. This becomes tedious, error prone, and difficult to read:

val colombs = 500.0 * 60 * 60 / 1000
val amperes = 3.7 / (10 * 1000)
val seconds = colombs / amperes
val days = seconds / 60 / 60 / 24
println(days)

But, with units-of-measure, all unit conversions happen automatically.
No magic constants. No massive variable names.

val discharge: Time = 500.milli(Ampere) * Hour / 3.7.Volt * 10.kilo(Ohm)
println(discharge.Day)

‹ Benefit: Faster Development Install ›› Benefit: Safe Flexibility ›