ExKcal.Calc.convert_si_unit

You're seeing just the function convert_si_unit, go back to ExKcal.Calc module for more information.
Link to this function

convert_si_unit(arg, unit_to)

Specs

convert_si_unit(weight() | volume(), atom()) :: weight() | volume()

Converts ExKcal.Units.weight() and ExKcal.Units.volume() type values to target unit.

Notes

There is some quirkiness to that function:

  • it converts from prefix to prefix, not really from unit to unit. This means that only prefix is taken into account during the conversion. Because of that, conversion between volume and weight units will go through (see examples).

Examples

iex> import ExKcal.Calc
iex> convert_si_unit({0.1, :mg}, :dl)
{0.001, :dl}
iex> convert_si_unit({1002.0, :g}, :kg)
{1.002, :kg}
iex> convert_si_unit({0.23, :dag}, :mg)
{2.3e3, :mg}