Units
Dewy was designed from day 1 to include physical units such as kilogram, meter, second.
A Simple Example
Using units is quite straightforward, as they are just another expression. Juxtaposing a unit with a number will multiply the number by the unit, and you can use this to build up more complex expressions.
The energy variable now contains a value of 9000 joules. For more complex unit expressions, sometimes it is necessary to use parentheses to group terms together. In general it is good style to do so, except for the simplest unit expressions. See Operator Precedence.
Here are several more examples of unit expressions:
SI Prefixes
Note: SI prefixes only work for SI base and derived units (and a few exceptions noted below). Also the abbreviated forms of prefixes may only be combined with abbreviated units, and written out prefixes may only be combined with written out units. E.g.
kilogramsandkgare valid, butkgramsandkilogare invalid.
| Prefix | Abbrev. | Scale |
|---|---|---|
yotta | Y | 10^24 |
zetta | Z | 10^21 |
exa | E | 10^18 |
peta | P | 10^15 |
tera | T | 10^12 |
giga | G | 10^9 |
mega | M | 10^6 |
kilo | k | 10^3 |
hecto | h | 10^2 |
deca | da | 10^1 |
deci | d | 10^−1 |
centi | c | 10^−2 |
milli | m | 10^−3 |
micro | μ/u | 10^−6 |
nano | n | 10^−9 |
pico | p | 10^−12 |
femto | f | 10^−15 |
atto | a | 10^−18 |
zepto | z | 10^−21 |
yocto | y | 10^−24 |
Non-SI units that may receive SI prefixes:
psi(e.g.kpsi=1000(psi))torr(e.g.mTorr=0.001(torr))bar(e.g.mbar=0.001(bar))eV(e.g.keV=1000(eV))cal(e.g.kcal=1000(cal))- (TODO: probably more)
Binary Prefixes
Note: These prefixes are exclusively for use with units of information (e.g.
bit/byte)
| Prefix | Abbrev. | Scale |
|---|---|---|
kibi | Ki | 2^10 |
mebi | Mi | 2^20 |
gibi | Gi | 2^30 |
tebi | Ti | 2^40 |
pebi | Pi | 2^50 |
exbi | Ei | 2^60 |
zebi | Zi | 2^70 |
yobi | Yi | 2^80 |
Full List of Units
(TODO->maybe like solidworks, allow user to set unit system, e.g. meters-kilograms-seconds, centimeters-grams-seconds, etc. See: https://en.wikipedia.org/wiki/MKS_system_of_units https://en.wikipedia.org/wiki/Metre%E2%80%93tonne%E2%80%93second_system_of_units https://en.wikipedia.org/wiki/Foot%E2%80%93pound%E2%80%93second_system https://en.wikipedia.org/wiki/Centimetre%E2%80%93gram%E2%80%93second_system_of_units )
Base Units
Note: abbreviated units and prefixes are case sensitive, while fully written out units and prefixes are case insensitive
| Quantity | Symbol | Abbrev. Units | Full Units |
|---|---|---|---|
| Mass* | [M] | gklbm- | gram/gramskilo/kilospound-mass/pounds-massslug/slugs |
| Length | [L] | m- ftydmi- AU- - | meter/meters/metre/metresinch/inchesfoot/feetyard/yardsmile/milesnautical_mile/nautical_milesastronomical_unit/astronomical_unitslight_year/light_yearsparsec/parsecs |
| Time | [T] | s- - - - - - - - - | second/secondsminute/minuteshour/hoursday/daysweek/weeksmonth/monthsyear/yearsdecade/decadescentury/centuriesmillennium/millennia |
| Electric Current | [I] | A | amp/amps/ampere/amperes |
| Thermodynamic Temperature | [Θ] | K°R/°Ra°C°F | kelvinrankine/degrees_rankinecelsius/degrees_celsiusfahrenheit/degrees_fahrenheit |
| Amount of Substance | [N] | mol | mole/moles |
| Luminous Intensity | [J] | cd | candela/candelas |
(TODO: metric vs us vs etc. tons)
Note: in SI, the base unit for mass is
kg/kilograms, notg/grams.k/kilois provided as a convenience to allow for a mass base unit without a prefix. e.g.kilokilowould be equivalent to1000(kilograms).
(TODO: exact durations of longer units. e.g. sidereal day vs solar day, etc.)
Note: the plural of
kelviniskelvin, notkelvins
Named Derived Units
| Quantity | Abbrev. Units | Full Units |
|---|---|---|
| Plane Angle | rad° | radian/radiansdegree/degrees |
| Solid Angle | sr | steradian/steradians |
| Frequency | Hz | hertz |
| Force / Weight | Nlb/lbf | newton/newtonspound/pounds/pound-force/pounds-force |
| Pressure / Stress | PaatmbarpsitorrmmHginH2O | pascal/pascalsatmosphere/atmospheresbarpounds_per_square_inchtorrmillimeters_of_mercuryinches_of_water |
| Energy / Work / Heat | JcalCal*BTUeVWherg | joule/joulescalorie/calorieskilocalorie/kilocaloriesbritish_thermal_unit/british_thermal_unitselectron_volt/electron_voltswatt_hour/watt_hourserg/ergs |
| Power / Radiant Flux | Whp | watt/wattshorsepower |
| Electric Charge / Quantity of Electricity | C | coulomb/coulombs |
| Voltage / Electrical Potential / EMF | V | volt/volts |
| Capacitance | F | farad/farads |
| Reistance / Impedance / Reactance | Ω | ohm/ohms |
| Electrical Conductance | S | siemens |
| Magnetic Flux | Wb | weber/webers |
| Magnetic Flux Density | T | tesla/teslas |
| Inductance | H | henry/henries |
| Luminous Flux | lm | lumen/lumens |
| Illuminance | lx | lux/luxes |
| Radioactivity (Decays per unit time) | Bq | becquerel/becquerels |
| Absorbed Dose (of Ionizing Radiation) | Gy | gray/grays |
| Equivalent Dose (of Ionising Radiation) | Sv | sievert/sieverts |
| Catalytic Activity | kat | katal/katals |
Note:
Calis equivalent tokcalorkilocalorie(i.e.1000(calories)).
Weird Units
(TODO->all other units + weird units. e.g. drops)
Other Units
| Quantity | Abbrev. Units | Full Units |
|---|---|---|
| Information | b/bitB/byte | bit/bitsbyte/bytes |
(TODO: where do decibels go? B is already taken by byte... perhaps the user can select what units get imported by importing units from different domains, e.g. import units from si or import units from information)
(TODO: other units to add: Hz, liter, gallon, oz, phon/lufs/other sound intensity related units)