Closed tymokvo closed 4 months ago
your kilogram example works because kilograms is the base unit of mass, but if you were to use pounds instead
console.log(Measure.of(72, pounds).toString());
// prints: 32.658650640000005 kg
you should use .in
instead to print in a particular unit:
console.log(Measure.of(72, bytes).in(bytes));
Makes sense! But still confusing. Maybe a reference to the SI base units in the documentation would help? For those of us (like me :grimacing: ) who haven't taken physics for a while?
NIST has a good reference here, though it is US-centric. The ISO standard is paywalled, unfortunately.
I know I'm a little late on this (😬), but there is a reference to this in the documentation here: https://jscheiny.github.io/safe-units/builtin.html#base-units
Hello!
From the readme, I expected:
to print
72 B
but, the result is
576 b
as the underlying value created byMeasure.of
is in bits.This is a bit confusing as other higher order units behave as I would expect them to, e.g.:
yields
72 kg
rather than72000 g
.Using
v1.1.0
with Typescriptv4.3.5
.