ExKcal.SI (ExKcal v0.0.8)
Various SI prefixes-related functions etc.
Link to this section Summary
Types
Known SI prefixes.
Volume of substance and unit it is represented in.
Weight of substance and unit it is represented in.
Functions
Extracts SI prefix from the unit.
Calculates shift required for prefix conversion.
Returns index of SI prefix relative to base (non-)prefix position. Negative shift factor will have negative index, positive factor will have positive index.
Returns list of tuples representing SI prefixes.
Link to this section Types
si_prefix()
Specs
si_prefix() :: :Y | :Z | :E | :P | :T | :G | :M | :k | :h | :da | :d | :c | :m | :μ | :n | :p | :f | :a | :z | :y
Known SI prefixes.
volume()
Specs
volume() :: {float(), :l | :dl | :ml} | {nil, :none}
Volume of substance and unit it is represented in.
weight()
Specs
weight() :: {float(), :kg | :g | :mg | :μg} | {nil, :none}
Weight of substance and unit it is represented in.
Link to this section Functions
extract_prefix(unit)
Specs
Extracts SI prefix from the unit.
Examples
iex> import ExKcal.SI
iex> extract_prefix(:kg)
:k
iex> extract_prefix(:dag)
:da
prefix_conversion_factor(from, to)
Specs
Calculates shift required for prefix conversion.
Examples
iex> import ExKcal.SI
iex> prefix_conversion_factor(:m, :M)
-9
iex> prefix_conversion_factor(:G, :m)
12
prefix_index(prefix)
Specs
Returns index of SI prefix relative to base (non-)prefix position. Negative shift factor will have negative index, positive factor will have positive index.
Examples
iex> import ExKcal.SI
iex> prefix_index(:m)
-3
iex> prefix_index(:M)
6
prefixes()
Specs
Returns list of tuples representing SI prefixes.