Skip to content

The Unit Solver

饺子w (Yumechi) edited this page Aug 23, 2023 · 2 revisions

UnitDC can linearly combine quantities automatically so you do not have to manually multiply or divide yourself.

Workflow

  • Input all known quantities
  • Input the number of known quantities and the output unit, for example if you have 3 known quantities and you want your output in (m/s), put 3 (m) 1 (s) /
  • Invoke the s operator
  • The solution will be pushed onto top of stack

Example

We want to convert the electricity price of an electric vehicle to equivalent gas mpg:

@base(usd) # define usd as a base unit
0 (mi) 1 (gal) / 1 (mi) 1 (gal) / @derived(mpg) # define mpg as 1 mile per gallon
3.4 (usd) 1 (gal) / # gas price
0.36 (usd) 1 (kWh) / # electricity price
36 (kWh) 100 (mi) / # electricity consumption
3 (mpg) sp # solve for mpg

Or without defining the mpg unit:

@base(usd) # define usd as a base unit
3.4 (usd) 1 (gal) / # gas price
0.36 (usd) 1 (kWh) / # electricity price
36 (kWh) 100 (mi) / # electricity consumption
3 (mi) 1 (gal) / sp # solve for mpg
Clone this wiki locally