These arithmetic operators for quantities in microbialkitchen keep track of units in standard operations (i.e. they ALL take the SI prefix into consideration). Also note that all operations that result in a new quantity object automatically scale the new value using best_metric.

## Arguments

qty quantity regular number

## Details

qty ==, !=, <, <=, >, >= qty allows the comparison of quantities that are the same type (e.g. all mass).

qty / number divide quantity by a plain number. Returns the quantity automatically rescaled to the best metric.

qty * number multiply a quantity by a plain number (either way around is valid). Returns the quantity automatically rescaled to the best metric.

qty +- qty allows the addition/subtraction of quantities that are the same type (e.g. all mass). Note that this operation also scales the new value using best_metric.

qty / qty divide quantities of the same type. Returns plain numeric (i.e. the units are divided out).

amount / volume divide an amount by a volume to create a molarity (concentration).

amount / molarity divide an amount by a molarity concentration to create a volume.

molarity * volume multiply a molarity concentration by a volume (or the other way around) to create an amount.

mass / volume divide a mass by a volume to create mass concentration (density).

mass / density divide a mass by a mass concentration (density) to create a volume.

density * volume multiply a mass concentration (density) by a volume (or the other way around) to create a mass.

mass / MW divide a mass by a molecular weight to create an amount (mols).

mass / amount divide a mass by an amount (mols) to create a molecular weight.

amount * MW multiply an amount (mols) by a molecular weight to create a mass.

molarity / pressure divide a concentration by pressure to create a gas solubility (M/bar).

molarity / solubility divide a molarity (M) by a gas solubility (M/bar) to get partial pressure (bar)

solubility * pressure multiply a gas solubility (M/bar) by pressure (bar) to create molarity (M)

## Examples

qty(1, "g") == qty(1000, "mg", scale_to_best_metric = FALSE) # TRUE
#>  TRUEqty(2, "mg") < qty(5, "ng")  # FALSE
#>  FALSEqty(5, "mg") / 1e6 # 5 ng
#> <m (mass) in 'ng'>
#>  5qty(5, "mg") * 1e6 # 5 kg
#> <m (mass) in 'kg'>
#>  5qty(1, "mg") + qty(999.999, "g") # 1 kg
#> <m (mass) in 'kg'>
#>  1qty(5, "mg") / qty(1, "g") # 0.005
#>  0.005qty(5, "nmol") / qty(50, "mL") # 100 nM
#> <C (molarity concentration) in 'nM'>
#>  100qty(5, "nmol") / qty(100, "nM") # 50 mL
#> <V (volume) in 'mL'>
#>  50qty(100, "nM") * qty(50, "mL") # 5 nmol
#> <N (amount) in 'nmol'>
#>  5qty(5, "ng") / qty(50, "mL") # 100 ng/L
#> <C (mass concentration) in 'ng/L'>
#>  100qty(5, "ng") / qty(100, "ng/L") # 50 mL
#> <V (volume) in 'mL'>
#>  50qty(100, "ng/L") * qty(50, "mL") # 5 ng
#> <m (mass) in 'ng'>
#>  5qty(10, "g") / qty (50, "g/mol") # 200 mmol
#> <N (amount) in 'mmol'>
#>  200qty(10, "g") / qty(200, "mmol") # 50 g/mol
#> <MW (molecular weight) in 'g/mol'>
#>  50qty(200, "mmol") * qty (50, "g/mol") # 10 g
#> <m (mass) in 'g'>
#>  10qty(10, "mM") / qty(200, "mbar") # 50 mM/bar
#> <S (gas solubility) in 'mM/bar'>
#>  50qty(10, "mM") / qty(50, "mM/bar") # 200 mbar
#> <P (pressure) in 'mbar'>
#>  200qty(50, "mM/bar") * qty (200, "mbar") # 10 mM
#> <C (molarity concentration) in 'mM'>
#>  10