doug-101 / ConvertAll-py

a flexible unit converter
http://convertall.bellz.org
39 stars 15 forks source link

Suggestion: Add SI Units/Prefixes to units.dat #14

Open fdt-dev opened 3 years ago

fdt-dev commented 3 years ago

In many cases it can be helpful to be able to add a SI prefix (for example mega or giga or yotta) to a unit. (Actually to be precise: multiply a SI prefix with the unit). My proposal therefore would be to add SI prefixes to the file units.dat as unitless numbers. Here's what that could look like:

[SI prefixes]
yotta              = 1000 zetta
zetta              = 1000 exa
exa                = 1000 peta
peta               = 1000 tera
tera               = 1000 giga
giga               = 1000 mega
mega               = 1000 kilo
kilo               = 1000 unit
hekto              = 100 unit
deca               = 10 unit
deci               = 0.1 unit
centi              = 0.01 unit
milli              = 0.001 unit
micro              = 0.001 milli
nano               = 0.001 micro
pico               = 0.001 nano
femto              = 0.001 pico
atto               = 0.001 femto
zepto              = 0.001 atto
yocto              = 0.001 zepto

Tested and working. For example in order to get the unit GeV (Giga Electronvolt) with the above entries in units.dat it is possible to enter "giga ev" into the unit entry. ConvertAll correctly translates that to 1E+09 eV. Same for "pico Farad" --> 1E-12 Farad.