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

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.

Specs

volume() :: {float(), :l | :dl | :ml} | {nil, :none}

Volume of substance and unit it is represented in.

Specs

weight() :: {float(), :kg | :g | :mg | :μg} | {nil, :none}

Weight of substance and unit it is represented in.

Link to this section Functions

Link to this function

extract_prefix(unit)

Specs

extract_prefix(atom()) :: si_prefix()

Extracts SI prefix from the unit.

Examples

iex> import ExKcal.SI
iex> extract_prefix(:kg)
:k
iex> extract_prefix(:dag)
:da
Link to this function

prefix_conversion_factor(from, to)

Specs

prefix_conversion_factor(si_prefix(), si_prefix()) :: integer()

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
Link to this function

prefix_index(prefix)

Specs

prefix_index(si_prefix()) :: integer()

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

Specs

prefixes() :: [{atom() | nil, si_prefix() | nil, number()}]

Returns list of tuples representing SI prefixes.