Cldr.Unit.Math.sub
You're seeing just the function
sub
, go back to Cldr.Unit.Math module for more information.
Specs
sub(Cldr.Unit.t(), Cldr.Unit.t()) :: Cldr.Unit.t() | {:error, {module(), String.t()}}
Subtracts two compatible %Unit{}
types
Options
unit_1
andunit_2
are compatible Units returned byCldr.Unit.new/2
Returns
A
%Unit{}
of the same type asunit_1
with a value that is the difference betweenunit_1
and the potentially convertedunit_2
{:error, {IncompatibleUnitError, message}}
Examples
iex> Cldr.Unit.sub Cldr.Unit.new!(:kilogram, 5), Cldr.Unit.new!(:pound, 1)
#Cldr.Unit<:kilogram, -81900798833369519 <|> 18014398509481984>
iex> Cldr.Unit.sub Cldr.Unit.new!(:pint, 5), Cldr.Unit.new!(:liter, 1)
#Cldr.Unit<:pint, -36794683014431043834033898368027039378825884348261 <|> 12746616238742849396626455585282990375683527307233>
iex> Cldr.Unit.sub Cldr.Unit.new!(:pint, 5), Cldr.Unit.new!(:pint, 1)
#Cldr.Unit<:pint, 4>