diff -Nru units-2.16/configure units-2.19/configure --- units-2.16/configure 2017-10-31 09:49:14.000000000 +0000 +++ units-2.19/configure 2019-05-24 23:15:50.000000000 +0000 @@ -1,6 +1,6 @@ #! /bin/sh # Guess values for system-dependent variables and create Makefiles. -# Generated by GNU Autoconf 2.69 for GNU units 2.16. +# Generated by GNU Autoconf 2.69 for GNU units 2.19. # # Report bugs to . # @@ -580,8 +580,8 @@ # Identity of this package. PACKAGE_NAME='GNU units' PACKAGE_TARNAME='units' -PACKAGE_VERSION='2.16' -PACKAGE_STRING='GNU units 2.16' +PACKAGE_VERSION='2.19' +PACKAGE_STRING='GNU units 2.19' PACKAGE_BUGREPORT='adrianm@gnu.org' PACKAGE_URL='http://www.gnu.org/software/units/' @@ -645,6 +645,9 @@ MKS_POSIX PYTHON_VERSION HAVE_PYTHON +RELOCATION +UDATADIR +CDAT UDAT STRFUNC DEFIS @@ -1251,7 +1254,7 @@ # Omit some internal or obsolete options to make the list less imposing. # This message is too long to be a string in the A/UX 3.1 sh. cat <<_ACEOF -\`configure' configures GNU units 2.16 to adapt to many kinds of systems. +\`configure' configures GNU units 2.19 to adapt to many kinds of systems. Usage: $0 [OPTION]... [VAR=VALUE]... @@ -1318,7 +1321,7 @@ if test -n "$ac_init_help"; then case $ac_init_help in - short | recursive ) echo "Configuration of GNU units 2.16:";; + short | recursive ) echo "Configuration of GNU units 2.19:";; esac cat <<\_ACEOF @@ -1407,7 +1410,7 @@ test -n "$ac_init_help" && exit $ac_status if $ac_init_version; then cat <<\_ACEOF -GNU units configure 2.16 +GNU units configure 2.19 generated by GNU Autoconf 2.69 Copyright (C) 2012 Free Software Foundation, Inc. @@ -1822,7 +1825,7 @@ This file contains any messages produced by compilers while running configure, to aid debugging if configure makes a mistake. -It was created by GNU units $as_me 2.16, which was +It was created by GNU units $as_me 2.19, which was generated by GNU Autoconf 2.69. Invocation command line was $ $0 $@ @@ -2194,6 +2197,10 @@ + +RELOCATION=no + + saveCFLAGS=$CFLAGS ac_ext=c @@ -2971,6 +2978,17 @@ +case $OSTYPE in + darwin*) + echo detected MacOS, setting flags + CPPFLAGS="$CPPFLAGS -I/opt/local/include" + LDFLAGS="$LDFLAGS -L/opt/local/lib" + ;; + *) echo detected non-mac os: $OSTYPE + +esac + + if test "$CC" = cl.exe; then if test -z "$saveCFLAGS" ; then @@ -3328,13 +3346,13 @@ -{ ac_cv_lib_readline_readline=; unset ac_cv_lib_readline_readline;} +{ ac_cv_lib_readline_append_history=; unset ac_cv_lib_readline_append_history;} for termlib in "" -ltermcap -lncurses -lcurses; do - if test "$ac_cv_lib_readline_readline" != yes ; then - { ac_cv_lib_readline_readline=; unset ac_cv_lib_readline_readline;} - { $as_echo "$as_me:${as_lineno-$LINENO}: checking for readline in -lreadline" >&5 -$as_echo_n "checking for readline in -lreadline... " >&6; } -if ${ac_cv_lib_readline_readline+:} false; then : + if test "$ac_cv_lib_readline_append_history" != yes ; then + { ac_cv_lib_readline_append_history=; unset ac_cv_lib_readline_append_history;} + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for append_history in -lreadline" >&5 +$as_echo_n "checking for append_history in -lreadline... " >&6; } +if ${ac_cv_lib_readline_append_history+:} false; then : $as_echo_n "(cached) " >&6 else ac_check_lib_save_LIBS=$LIBS @@ -3348,34 +3366,36 @@ #ifdef __cplusplus extern "C" #endif -char readline (); +char append_history (); int main () { -return readline (); +return append_history (); ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : - ac_cv_lib_readline_readline=yes + ac_cv_lib_readline_append_history=yes else - ac_cv_lib_readline_readline=no + ac_cv_lib_readline_append_history=no fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_readline_readline" >&5 -$as_echo "$ac_cv_lib_readline_readline" >&6; } -if test "x$ac_cv_lib_readline_readline" = xyes; then : +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_readline_append_history" >&5 +$as_echo "$ac_cv_lib_readline_append_history" >&6; } +if test "x$ac_cv_lib_readline_append_history" = xyes; then : LIBS="-lreadline $termlib $LIBS";DEFIS="$DEFIS -DREADLINE" fi fi done -if test "$ac_cv_lib_readline_readline" = yes; then + + +if test "$ac_cv_lib_readline_append_history" = yes; then ac_fn_c_check_decl "$LINENO" "rl_completion_suppress_append" "ac_cv_have_decl_rl_completion_suppress_append" "#include " if test "x$ac_cv_have_decl_rl_completion_suppress_append" = xyes; then : @@ -4034,18 +4054,22 @@ # Check whether --enable-relocation was given. if test "${enable_relocation+set}" = set; then : enableval=$enable_relocation; if test $enable_relocation = yes ;then - UDAT="" + UDATADIR="" + RELOCATION="yes" echo relocation enabled else - UDAT="$datadir/units/" + UDATADIR="$datadir/units/" echo relocation disabled fi else - UDAT="$datadir/units/" + UDATADIR="$datadir/units/" fi +UDAT="$datadir/units/" +CDAT="$sharedstatedir/units/" + ac_config_files="$ac_config_files Makefile" @@ -4590,7 +4614,7 @@ # report actual input values of CONFIG_FILES etc. instead of their # values after options handling. ac_log=" -This file was extended by GNU units $as_me 2.16, which was +This file was extended by GNU units $as_me 2.19, which was generated by GNU Autoconf 2.69. Invocation command line was CONFIG_FILES = $CONFIG_FILES @@ -4645,7 +4669,7 @@ cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`" ac_cs_version="\\ -GNU units config.status 2.16 +GNU units config.status 2.19 configured by $0, generated by GNU Autoconf 2.69, with options \\"\$ac_cs_config\\" diff -Nru units-2.16/configure.ac units-2.19/configure.ac --- units-2.16/configure.ac 2017-10-31 09:49:03.000000000 +0000 +++ units-2.19/configure.ac 2019-05-24 22:39:13.000000000 +0000 @@ -1,13 +1,16 @@ -dnl Copyright (C) 2006, 2014, 2017 Free Software Foundation, Inc +dnl Copyright (C) 2006, 2014, 2017, 2018 Free Software Foundation, Inc dnl Process this file with autoconf to produce a configure script. -AC_INIT(GNU units,2.16,adrianm@gnu.org) +AC_INIT(GNU units,2.19,adrianm@gnu.org) AC_PREREQ(2.59) AC_ARG_PROGRAM AC_SUBST(DEFIS) AC_SUBST(STRFUNC) AC_SUBST(UDAT) +AC_SUBST(CDAT) +AC_SUBST(UDATADIR) +AC_SUBST(RELOCATION) AC_SUBST(HAVE_PYTHON) AC_SUBST(PYTHON_VERSION) AC_SUBST(MKS_POSIX) @@ -15,6 +18,7 @@ AC_SUBST(MKS_DRIVE) AC_SUBST(HAVE_MKS) +RELOCATION=no dnl Hack to set correct CFLAGS for cl compiler while still dnl allowing user to override the CFLAGS setting @@ -24,6 +28,17 @@ AC_PROG_CC(gcc cc egcs cl.exe) AC_PROG_CC_C99 +case $OSTYPE in + darwin*) + echo detected MacOS, setting flags + CPPFLAGS="$CPPFLAGS -I/opt/local/include" + LDFLAGS="$LDFLAGS -L/opt/local/lib" + ;; + *) echo detected non-mac os: $OSTYPE + +esac + + AC_DEFUN([AX_CHECK_COMPILE_FLAG], [AC_PREREQ(2.64)dnl for _AC_LANG_PREFIX and AS_VAR_IF AS_VAR_PUSHDEF([CACHEVAR],[ax_cv_check_[]_AC_LANG_ABBREV[]flags_$4_$1])dnl @@ -67,17 +82,19 @@ dnl Check for readline with various possible required support libs -AS_UNSET(ac_cv_lib_readline_readline) +AS_UNSET(ac_cv_lib_readline_append_history) for termlib in "" -ltermcap -lncurses -lcurses; do - if test "$ac_cv_lib_readline_readline" != yes ; then - AS_UNSET(ac_cv_lib_readline_readline) - AC_CHECK_LIB(readline,readline, + if test "$ac_cv_lib_readline_append_history" != yes ; then + AS_UNSET(ac_cv_lib_readline_append_history) + AC_CHECK_LIB(readline,append_history, [LIBS="-lreadline $termlib $LIBS";DEFIS="$DEFIS -DREADLINE"], [],[$termlib]) fi done -if test "$ac_cv_lib_readline_readline" = yes; then + + +if test "$ac_cv_lib_readline_append_history" = yes; then AC_CHECK_DECL(rl_completion_suppress_append, [], [DEFIS="$DEFIS -DNO_SUPPRESS_APPEND"], [[#include ]]) @@ -172,14 +189,18 @@ AC_ARG_ENABLE([relocation], AC_HELP_STRING([--enable-relocation], [look in program directory for units data files (default is NO)]), - [if test $enable_relocation = yes ;then - UDAT="" - echo relocation enabled - else - UDAT="$datadir/units/" + [if test $enable_relocation = yes ;then + UDATADIR="" + RELOCATION="yes" + echo relocation enabled + else + UDATADIR="$datadir/units/" echo relocation disabled fi - ], [UDAT="$datadir/units/"]) + ], [UDATADIR="$datadir/units/"]) + +UDAT="$datadir/units/" +CDAT="$sharedstatedir/units/" AC_CONFIG_FILES(Makefile) diff -Nru units-2.16/currency.units units-2.19/currency.units --- units-2.16/currency.units 2017-11-01 02:16:31.000000000 +0000 +++ units-2.19/currency.units 2019-05-31 22:35:38.000000000 +0000 @@ -10,8 +10,8 @@ GRD greecedrachma IEP irelandpunt ITL italylira -LVL latvialat -LTL lithuanialita +LVL latvialats +LTL lithuanialitas LUF luxembourgfranc MTL maltalira SKK slovakiakornua @@ -23,13 +23,14 @@ BGN bulgarialev BAM bosniaconvertiblemark KMF comorosfranc -XOF westafricanfranc +XOF westafricafranc XPF cfpfranc -XAF centralafricancfafranc +XAF centralafricacfafranc AED uaedirham AFN afghanafghani ALL albanialek AMD armeniadram +ANG antillesguilder AOA angolakwanza ARS argentinapeso AUD australiadollar @@ -39,12 +40,10 @@ BDT bangladeshtaka BHD bahraindinar BIF burundifranc -BMD bermudadollar BND bruneidollar BOB boliviaboliviano BRL brazilreal BSD bahamasdollar -BTN bhutanngultrum BWP botswanapula BYN belarusruble BYR oldbelarusruble @@ -64,10 +63,9 @@ DZD algeriadinar EGP egyptpound ERN eritreanakfa -ETB ethiopianbirr +ETB ethiopiabirr EUR euro FJD fijidollar -FKP falklandislandspound GBP ukpound GEL georgialari GHS ghanacedi @@ -93,15 +91,14 @@ KES kenyaschilling KGS kyrgyzstansom KHR cambodiariel -KPW northkoreawon KRW southkoreawon KWD kuwaitdinar -KYD caymanislandsdollar KZT kazakhstantenge LAK laokip LBP lebanonpound -LKR srilankanrupee +LKR srilankarupee LRD liberiadollar +LSL lesotholoti LYD libyadinar MAD moroccodirham MDL moldovaleu @@ -110,13 +107,14 @@ MMK myanmarkyat MNT mongoliatugrik MOP macaupataca -MRO mauritaniaouguiya +MRO mauritaniaoldouguiya +MRU mauritaniaouguiya MUR mauritiusrupee MVR maldiverufiyaa MWK malawikwacha MXN mexicopeso MYR malaysiaringgit -MZN mozambicanmetical +MZN mozambiquemetical NAD namibiadollar NGN nigerianaira NIO nicaraguacordobaoro @@ -142,11 +140,11 @@ SDG sudanpound SEK swedenkrona SGD singaporedollar -SHP sainthelenapound SLL sierraleoneleone SOS somaliaschilling SRD surinamedollar -STD saotome&principedobra +SSP southsudanpound +STN saotome&principedobra SVC elsalvadorcolon SYP syriapound SZL swazilandlilangeni @@ -161,206 +159,198 @@ TZS tanzaniashilling UAH ukrainehryvnia UGX ugandaschilling -USD unitedstatesdollar +USD US$ UYU uruguaypeso UZS uzbekistansum -VEF venezuelabolivar -VEB venezuelaoldbolivar +VES venezuelabolivarsoberano VND vietnamdong VUV vanuatuvatu WST samoatala XCD eastcaribbeandollar -XDR specialdrawingrights YER yemenrial ZAR southafricarand ZMW zambiakwacha -ZWL zimbabwedollar -# Currency exchange rates from Yahoo Finance (finance.yahoo.com) +# Currency exchange rates source -!message Currency exchange rates from finance.yahoo.com on 2017-10-31 +!message Currency exchange rates from FloatRates (USD base) on 2019-05-31 -austriaschilling 1|13.7603 euro -belgiumfranc 1|40.3399 euro -cypruspound 1|0.585274 euro -estoniakroon 1|15.6466 euro # Equal to 1|8 germanymark -finlandmarkka 1|5.94573 euro -francefranc 1|6.55957 euro -germanymark 1|1.95583 euro -greecedrachma 1|340.75 euro -irelandpunt 1|0.787564 euro -italylira 1|1936.27 euro -latvialat 1|0.620550 US$ -lithuanialita 1|3.048700 US$ -luxembourgfranc 1|40.3399 euro -maltalira 1|0.4293 euro -slovakiakornua 1|30.1260 euro -sloveniatolar 1|239.640 euro -spainpeseta 1|166.386 euro -netherlandsguilder 1|2.20371 euro -portugalescudo 1|200.482 euro -capeverdeescudo 1|94.809998 US$ -bulgarialev 1|1.680600 US$ -bosniaconvertiblemark 1|1.683500 US$ -comorosfranc 1|423.399994 US$ -westafricanfranc 1|655.957 euro -cfpfranc 1|119.33 euro -centralafricancfafranc 1|563.330017 US$ -uaedirham 1|3.672500 US$ -afghanafghani 1|68.290001 US$ -albanialek 1|114.349998 US$ -armeniadram 1|482.369995 US$ -angolakwanza 1|165.097000 US$ -argentinapeso 1|17.629000 US$ -australiadollar 1|1.305600 US$ -arubaflorin 1|1.780000 US$ -azerbaijanmanat 1|1.699700 US$ -barbadosdollar 1|2.000000 US$ -bangladeshtaka 1|82.779999 US$ -bahraindinar 1|0.376800 US$ -burundifranc 1|1740.550049 US$ -bermudadollar 1|1.000000 US$ -bruneidollar 1|1.362700 US$ -boliviaboliviano 1|6.860000 US$ -brazilreal 1|3.270700 US$ -bahamasdollar 1|1.000000 US$ -bhutanngultrum 1|64.775002 US$ -botswanapula 1|10.499200 US$ -belarusruble 1|1.950000 US$ -oldbelarusruble 10000 BYN -belizedollar 1|1.997800 US$ -canadadollar 1|1.290260 US$ -drcfranccongolais 1|1565.500000 US$ -swissfranc 1|0.999300 US$ -chilepeso 1|635.950012 US$ -chinayuan 1|6.634500 US$ -colombiapeso 1|3039.800049 US$ -costaricacolon 1|565.630005 US$ -cubapeso 1|1.000000 US$ -czechkoruna 1|22.050900 US$ -djiboutifranc 1|176.830002 US$ -denmarkkrona 1|6.396780 US$ -dominicanrepublicpeso 1|47.029999 US$ -algeriadinar 1|114.959999 US$ -egyptpound 1|17.600000 US$ -eritreanakfa 1|15.280000 US$ -ethiopianbirr 1|27.049999 US$ -euro 1|0.859400 US$ -fijidollar 1|2.075000 US$ -falklandislandspound 1|0.752200 US$ -ukpound 1|0.753260 US$ -georgialari 1|2.601200 US$ -ghanacedi 1|4.388500 US$ -gibraltarpound 1|0.752500 US$ -gambiadalasi 1|47.099998 US$ -guineafranc 1|8897.000000 US$ -guatemalaquetzal 1|7.343000 US$ -guyanadollar 1|204.289993 US$ -hongkongdollar 1|7.801500 US$ -honduraslempira 1|23.452000 US$ -croatiakuna 1|6.460700 US$ -haitigourde 1|61.610001 US$ -hungariaforint 1|267.369995 US$ -indonesiarupiah 1|13590.000000 US$ -israelnewshekel 1|3.516900 US$ -indiarupee 1|64.738998 US$ -iraqdinar 1|1166.000000 US$ -iranrial 1|34954.000000 US$ -icelandkrona 1|105.250000 US$ -jamaicadollar 1|125.879997 US$ -jordandinar 1|0.707500 US$ -japanyen 1|113.870003 US$ -kenyaschilling 1|103.449997 US$ -kyrgyzstansom 1|68.721001 US$ -cambodiariel 1|4042.000000 US$ -northkoreawon 1|900.000000 US$ -southkoreawon 1|1117.000000 US$ -kuwaitdinar 1|0.302100 US$ -caymanislandsdollar 1|0.820000 US$ -kazakhstantenge 1|334.820007 US$ -laokip 1|8295.000000 US$ -lebanonpound 1|1505.699951 US$ -srilankanrupee 1|153.550003 US$ -liberiadollar 1|118.900002 US$ -libyadinar 1|1.371700 US$ -moroccodirham 1|9.500000 US$ -moldovaleu 1|17.264999 US$ -madagascarariary 1|3145.000000 US$ -macedoniadenar 1|52.639999 US$ -myanmarkyat 1|1363.000000 US$ -mongoliatugrik 1|2448.000000 US$ -macaupataca 1|8.035300 US$ -mauritaniaouguiya 1|351.320007 US$ -mauritiusrupee 1|34.150002 US$ -maldiverufiyaa 1|15.570000 US$ -malawikwacha 1|716.150024 US$ -mexicopeso 1|19.164801 US$ -malaysiaringgit 1|4.232000 US$ -mozambicanmetical 1|60.200001 US$ -namibiadollar 1|14.134000 US$ -nigerianaira 1|356.000000 US$ -nicaraguacordobaoro 1|30.330000 US$ -norwaykrone 1|8.175880 US$ -nepalrupee 1|103.550003 US$ -newzealanddollar 1|1.449700 US$ -omanrial 1|0.384800 US$ -panamabalboa 1|1.000000 US$ -perunuevosol 1|3.248500 US$ -papuanewguineakina 1|3.207800 US$ -philippinepeso 1|51.619999 US$ -pakistanrupee 1|105.099998 US$ -polandzloty 1|3.643900 US$ -paraguayguarani 1|5623.000000 US$ -qatarrial 1|3.775600 US$ -romanianewlei 1|3.955400 US$ -serbiadinar 1|102.204498 US$ -russiaruble 1|58.318001 US$ -rwandafranc 1|831.270020 US$ -saudiarabiariyal 1|3.750000 US$ -solomonislandsdollar 1|7.810000 US$ -seychellesrupee 1|13.503000 US$ -sudanpound 1|6.659700 US$ -swedenkrona 1|8.379910 US$ -singaporedollar 1|1.363340 US$ -sainthelenapound 1|0.752500 US$ -sierraleoneleone 1|7620.000000 US$ -somaliaschilling 1|559.000000 US$ -surinamedollar 1|7.380000 US$ -saotome&principedobra 1|21066.199219 US$ -elsalvadorcolon 1|8.750000 US$ -syriapound 1|514.979980 US$ -swazilandlilangeni 1|14.138000 US$ -thailandbaht 1|33.160000 US$ -tajikistansomoni 1|8.803300 US$ -turkmenistanmanat 1|3.410000 US$ -tunisiadinar 1|2.495700 US$ -tongapa'anga 1|2.289000 US$ -turkeylira 1|3.790800 US$ -trinidadandtobagodollar 1|6.724700 US$ -taiwandollar 1|30.163000 US$ -tanzaniashilling 1|2239.000000 US$ -ukrainehryvnia 1|26.870001 US$ -ugandaschilling 1|3644.000000 US$ -unitedstatesdollar US$ -uruguaypeso 1|29.200001 US$ -uzbekistansum 1|8061.000000 US$ -venezuelabolivar 1|9.974500 US$ -venezuelaoldbolivar 1000 VEF -vietnamdong 1|22699.000000 US$ -vanuatuvatu 1|106.190002 US$ -samoatala 1|2.572200 US$ -eastcaribbeandollar 1|2.700000 US$ -specialdrawingrights 1|0.711903 US$ -yemenrial 1|249.949997 US$ -southafricarand 1|14.135100 US$ -zambiakwacha 1|10.000000 US$ -zimbabwedollar 1|322.355011 US$ -bitcoin 6370.11 US$ # From services.packetizer.com/btc +austriaschilling 1|13.7603 euro +belgiumfranc 1|40.3399 euro +cypruspound 1|0.585274 euro +estoniakroon 1|15.6466 euro # Equal to 1|8 germanymark +finlandmarkka 1|5.94573 euro +francefranc 1|6.55957 euro +germanymark 1|1.95583 euro +greecedrachma 1|340.75 euro +irelandpunt 1|0.787564 euro +italylira 1|1936.27 euro +latvialats 1|0.702804 euro +lithuanialitas 1|3.4528 euro +luxembourgfranc 1|40.3399 euro +maltalira 1|0.4293 euro +slovakiakornua 1|30.1260 euro +sloveniatolar 1|239.640 euro +spainpeseta 1|166.386 euro +netherlandsguilder 1|2.20371 euro +portugalescudo 1|200.482 euro +capeverdeescudo 0.0101044210089 USD +bulgarialev 0.569832695195 USD +bosniaconvertiblemark 0.571172528443 USD +comorosfranc 0.00227440386514 USD +westafricafranc 1|655.957 euro +cfpfranc 1|119.33 euro +centralafricacfafranc 0.00168809696578 USD +uaedirham 0.272294233532 USD +afghanafghani 0.0125076627357 USD +albanialek 0.00908047171282 USD +armeniadram 0.00208237913772 USD +antillesguilder 0.534183593953 USD +angolakwanza 0.00303911891527 USD +argentinapeso 0.022425572153 USD +australiadollar 0.691924138002 USD +arubaflorin 0.553301470206 USD +azerbaijanmanat 0.589424489635 USD +barbadosdollar 0.500137771884 USD +bangladeshtaka 0.0118358067087 USD +bahraindinar 2.65432622511 USD +burundifranc 0.000546002389735 USD +bruneidollar 0.724959291959 USD +boliviaboliviano 0.14519949806 USD +brazilreal 0.251192789606 USD +bahamasdollar 1.00145462102 USD +botswanapula 0.0928468743331 USD +belarusruble 0.477369511625 USD +oldbelarusruble 1|10000 BYN +belizedollar 0.496908930334 USD +canadadollar 0.738998182015 USD +drcfranccongolais 0.000608343290561 USD +swissfranc 0.994429717702 USD +chilepeso 0.00141176656462 USD +chinayuan 0.144801330126 USD +colombiapeso 0.000297363808638 USD +costaricacolon 0.00170175074365 USD +cubapeso 1.00145462102 USD +czechkoruna 0.0431115375124 USD +djiboutifranc 0.00562600654579 USD +denmarkkrona 0.149253655362 USD +dominicanrepublicpeso 0.0198192113876 USD +algeriadinar 0.00835430970538 USD +egyptpound 0.0595867283947 USD +eritreanakfa 0.0664450101304 USD +ethiopiabirr 0.0346771260845 USD +euro 1.11429646845 USD +fijidollar 0.464257883526 USD +ukpound 1.26153920067 USD +georgialari 0.357706893865 USD +ghanacedi 0.188789028001 USD +gibraltarpound 1.26614369578 USD +gambiadalasi 0.0198451867629 USD +guineafranc 0.000109616083952 USD +guatemalaquetzal 0.129902852096 USD +guyanadollar 0.00477037768196 USD +hongkongdollar 0.127440900637 USD +honduraslempira 0.0409371915424 USD +croatiakuna 0.150134699061 USD +haitigourde 0.0109616083952 USD +hungariaforint 0.0034294207435 USD +indonesiarupiah 6.95865312836e-05 USD +israelnewshekel 0.275704154063 USD +indiarupee 0.0143233712752 USD +iraqdinar 0.000839524131124 USD +iranrial 2.38529210867e-05 USD +icelandkrona 0.00804248688156 USD +jamaicadollar 0.0073510312224 USD +jordandinar 1.41233493639 USD +japanyen 0.00918008626144 USD +kenyaschilling 0.00988207179594 USD +kyrgyzstansom 0.0142898470647 USD +cambodiariel 0.000245467297002 USD +southkoreawon 0.000839675225101 USD +kuwaitdinar 3.28846922998 USD +kazakhstantenge 0.00261577255379 USD +laokip 0.000115070912775 USD +lebanonpound 0.000660752285911 USD +srilankarupee 0.00568107434152 USD +liberiadollar 0.00529897657021 USD +lesotholoti 0.0674580497688 USD +libyadinar 0.715361836979 USD +moroccodirham 0.10286107151 USD +moldovaleu 0.0549249984388 USD +madagascarariary 0.000273001194867 USD +macedoniadenar 0.0181645799782 USD +myanmarkyat 0.000652501428646 USD +mongoliatugrik 0.000378720972518 USD +macaupataca 0.123876565016 USD +mauritaniaoldouguiya 1|10 MRU +mauritaniaouguiya 0.0270143903579 USD +mauritiusrupee 0.0282229704927 USD +maldiverufiyaa 0.0647825861084 USD +malawikwacha 0.0013512390254 USD +mexicopeso 0.0515379189303 USD +malaysiaringgit 0.238302191557 USD +mozambiquemetical 0.0161047327134 USD +namibiadollar 0.0674060990181 USD +nigerianaira 0.0032628410721 USD +nicaraguacordobaoro 0.0303517893009 USD +norwaykrone 0.113999227235 USD +nepalrupee 0.00894591926853 USD +newzealanddollar 0.651260761699 USD +omanrial 2.59826484493 USD +panamabalboa 1.00145462102 USD +perunuevosol 0.297608988204 USD +papuanewguineakina 0.29551750023 USD +philippinepeso 0.0191643579797 USD +pakistanrupee 0.00662852410795 USD +polandzloty 0.259643935488 USD +paraguayguarani 0.000158409745144 USD +qatarrial 0.273546677749 USD +romanianewlei 0.234502601246 USD +serbiadinar 0.009461386826 USD +russiaruble 0.0153344749757 USD +rwandafranc 0.00110213517585 USD +saudiarabiariyal 0.266645771679 USD +solomonislandsdollar 0.124889604655 USD +seychellesrupee 0.0732245830952 USD +sudanpound 0.0222089459193 USD +swedenkrona 0.104589432619 USD +singaporedollar 0.725207344 USD +sierraleoneleone 0.000110655098966 USD +somaliaschilling 0.00173125876669 USD +surinamedollar 0.133980986025 USD +southsudanpound 0.00633980986025 USD +saotome&principedobra 0.0455348329783 USD +elsalvadorcolon 0.114421528391 USD +syriapound 0.00194815315081 USD +swazilandlilangeni 0.0674320743935 USD +thailandbaht 0.0314820697102 USD +tajikistansomoni 0.106008233005 USD +turkmenistanmanat 0.286192631879 USD +tunisiadinar 0.334199179178 USD +tongapa'anga 0.439815055328 USD +turkeylira 0.169734054462 USD +trinidadandtobagodollar 0.147877811834 USD +taiwandollar 0.0316263165797 USD +tanzaniashilling 0.000435866798275 USD +ukrainehryvnia 0.037214106022 USD +ugandaschilling 0.000266507351031 USD +US$ ! # Base unit, the primitive unit of currency +uruguaypeso 0.0284695723084 USD +uzbekistansum 0.000117908173048 USD +venezuelabolivarsoberano 0.000172888964033 USD +vietnamdong 4.27328581423e-05 USD +vanuatuvatu 0.00856538001974 USD +samoatala 0.378045612759 USD +eastcaribbeandollar 0.369915320276 USD +yemenrial 0.00401111746065 USD +southafricarand 0.0679688184146 USD +zambiakwacha 0.075172736246 USD +bitcoin 8512.16 US$ # From services.packetizer.com/btc # Precious metals prices from Packetizer (services.packetizer.com/spotprices) -platinumprice 920.00 US$/troyounce -silverprice 16.72 US$/troyounce -goldprice 1271.05 US$/troyounce +silverprice 14.52 US$/troyounce +goldprice 1288.30 US$/troyounce +platinumprice 797.00 US$/troyounce diff -Nru units-2.16/debian/changelog units-2.19/debian/changelog --- units-2.16/debian/changelog 2017-11-02 21:55:45.000000000 +0000 +++ units-2.19/debian/changelog 2019-10-30 19:23:07.000000000 +0000 @@ -1,3 +1,73 @@ +units (2.19-1~18.04) bionic; urgency=medium + + * Backport. + + -- DNS Wed, 30 Oct 2019 20:23:07 +0100 + +units (2.19-1) unstable; urgency=medium + + * Upload to unstable. + * Standards-Version 4.4.0, no change required. + + -- Stephen Kitt Thu, 15 Aug 2019 21:15:21 +0200 + +units (2.19-1~exp1) experimental; urgency=medium + + * New upstream release. + - Continuation paragraphs are indented in the manpage. + Closes: #921160. + - The AUTHORS section of the manpage is now filled in. + Closes: #926559. + * Update debian/copyright. + * Standards-Version 4.3.0, no further change required. + * Switch to debhelper compatibility level 12. + + -- Stephen Kitt Sat, 01 Jun 2019 14:09:02 +0200 + +units (2.18-1) unstable; urgency=medium + + * New upstream release. + - New currency sources replace the Yahoo! service which is no longer + available. Closes: #910503. + - Downloaded data is validated before being interpreted. + Closes: #902935. + * Set “Rules-Requires-Root: no”. + * Standards-Version 4.2.1, no further change required. + + -- Stephen Kitt Mon, 22 Oct 2018 10:22:02 +0200 + +units (2.17-3) unstable; urgency=medium + + * Actually remove the cron.daily file on upgrade. + + -- Stephen Kitt Sun, 08 Jul 2018 23:36:59 +0200 + +units (2.17-2) unstable; urgency=medium + + * Avoid calculating the MD5 sum of the shipped currency.units since it + is intended to be overwritten eventually. Closes: #902929. + * Drop the cron job, it should be up to individual users when currencies + are updated. Closes: #902890, #903317. + + -- Stephen Kitt Sun, 08 Jul 2018 23:24:27 +0200 + +units (2.17-1) unstable; urgency=medium + + * New upstream release, handling Yahoo currency updates correctly. + Closes: #900587. + * Add a cron job to update currencies daily. + + -- Stephen Kitt Tue, 26 Jun 2018 23:03:38 +0200 + +units (2.16-2) unstable; urgency=medium + + * Migrate to Salsa. + * Explicitly recommend python3. + * Switch to debhelper compatibility level 11. + * Standards-Version 4.1.4, no further change required. + + -- Stephen Kitt Thu, 17 May 2018 00:46:42 +0200 + units (2.16-1) unstable; urgency=medium * New upstream release. @@ -410,5 +480,3 @@ * Initial release. -- James Troup Sun, 19 Jan 1997 20:44:33 +0000 - - diff -Nru units-2.16/debian/compat units-2.19/debian/compat --- units-2.16/debian/compat 2017-06-19 20:51:01.000000000 +0000 +++ units-2.19/debian/compat 1970-01-01 00:00:00.000000000 +0000 @@ -1 +0,0 @@ -10 diff -Nru units-2.16/debian/control units-2.19/debian/control --- units-2.16/debian/control 2017-10-26 17:06:40.000000000 +0000 +++ units-2.19/debian/control 2019-08-15 19:14:24.000000000 +0000 @@ -3,20 +3,21 @@ Section: utils Priority: optional Build-Depends: bison, - debhelper (>= 10), + debhelper-compat (= 12), libreadline-dev, python3, texinfo -Standards-Version: 4.1.1 -Vcs-Browser: https://anonscm.debian.org/cgit/collab-maint/units.git -Vcs-Git: https://anonscm.debian.org/git/collab-maint/units.git +Standards-Version: 4.4.0 +Vcs-Browser: https://salsa.debian.org/debian/units +Vcs-Git: https://salsa.debian.org/debian/units.git Homepage: https://www.gnu.org/software/units/ +Rules-Requires-Root: no Package: units Architecture: any Depends: ${misc:Depends}, ${shlibs:Depends} -Recommends: python3-requests +Recommends: python3, python3-requests Description: converts between different systems of units GNU 'units' program converts quantities expressed in various scales to their equivalents in other scales. The 'units' program can only diff -Nru units-2.16/debian/copyright units-2.19/debian/copyright --- units-2.16/debian/copyright 2017-10-25 20:54:10.000000000 +0000 +++ units-2.19/debian/copyright 2019-06-01 12:05:40.000000000 +0000 @@ -3,7 +3,7 @@ Source: https://www.gnu.org/software/units/ Files: * -Copyright: 1984-2017 Free Software Foundation, Inc. +Copyright: 1984-2019 Free Software Foundation, Inc. License: GPL-3+ Files: getopt.h @@ -11,13 +11,13 @@ License: GPL-2+ Files: units.info units.pdf units.texinfo units.txt -Copyright: 1996-2017 Free Software Foundation, Inc. +Copyright: 1996-2019 Free Software Foundation, Inc. License: GFDL-1.3+ Files: debian/* Copyright: 1997-1998 James Troup 1999-2012 John G. Hasler - 2013-2017 Stephen Kitt + 2013-2019 Stephen Kitt License: GPL-2+ License: GPL-2+ diff -Nru units-2.16/debian/lintian-overrides units-2.19/debian/lintian-overrides --- units-2.16/debian/lintian-overrides 2015-10-18 21:24:51.000000000 +0000 +++ units-2.19/debian/lintian-overrides 1970-01-01 00:00:00.000000000 +0000 @@ -1,2 +0,0 @@ -# Python is recommended -units: python-script-but-no-python-dep usr/bin/units_cur diff -Nru units-2.16/debian/patches/manpage-typos.patch units-2.19/debian/patches/manpage-typos.patch --- units-2.16/debian/patches/manpage-typos.patch 2017-10-26 09:39:52.000000000 +0000 +++ units-2.19/debian/patches/manpage-typos.patch 2018-10-22 08:12:11.000000000 +0000 @@ -4,7 +4,7 @@ --- a/units.texinfo +++ b/units.texinfo -@@ -2104,8 +2104,8 @@ +@@ -2592,8 +2592,8 @@ @item -H @var{filename} @itemx --history @var{filename} @@ -15,7 +15,7 @@ Instruct @command{units} to save history to @var{filename}, so that a record of your commands is available for retrieval across different @command{units} invocations. To prevent the history from being saved -@@ -3274,7 +3274,7 @@ +@@ -3777,7 +3777,7 @@ with the choice of English customary units outside of English-speaking countries. To address this, @command{units} allows specifying definitions that depend on environment variable settings. diff -Nru units-2.16/debian/patches/no-currency-update.patch units-2.19/debian/patches/no-currency-update.patch --- units-2.16/debian/patches/no-currency-update.patch 2016-06-25 20:57:43.000000000 +0000 +++ units-2.19/debian/patches/no-currency-update.patch 2018-10-22 08:12:05.000000000 +0000 @@ -3,12 +3,12 @@ --- a/Makefile.in +++ b/Makefile.in -@@ -132,7 +132,7 @@ +@@ -110,7 +110,7 @@ -e "s@/usr/bin/python@$(PYTHON)@" \ - units_cur > units_cur_inst + $(srcdir)/units_cur > units_cur_inst --install-support: definitions.units currency.units units_cur_inst +-install-support: definitions.units units_cur_inst currency-units-update +install-support: definitions.units units_cur_inst - $(MKDIR_P) $(DESTDIR)@UDAT@ $(DESTDIR)$(bindir) + $(MKDIR_P) $(DESTDIR)@UDAT@ $(DESTDIR)$(bindir) $(DESTDIR)@CDAT@ $(INSTALL_DATA) $(srcdir)/definitions.units $(DESTDIR)@UDAT@definitions.units - $(INSTALL_DATA) $(srcdir)/currency.units $(DESTDIR)@UDAT@currency.units + -rm -f $(DESTDIR)@UDAT@currency.units diff -Nru units-2.16/debian/patches/pager.patch units-2.19/debian/patches/pager.patch --- units-2.16/debian/patches/pager.patch 2015-10-18 18:07:25.000000000 +0000 +++ units-2.19/debian/patches/pager.patch 2018-10-22 08:11:38.000000000 +0000 @@ -3,10 +3,10 @@ --- a/units.c +++ b/units.c -@@ -116,7 +116,7 @@ - #define HELPCOMMAND "help" /* Command to request help at prompt */ - #define SEARCHCOMMAND "search" /* Command to request text search of units */ - #define UNITMATCH "?" /* Command to request conformable units */ +@@ -112,7 +112,7 @@ + /* and in nonunitchars defined in parse.y */ + #define FUNCSEPCHAR ';' /* Separates forward and inverse definitions */ + #define REDEFCHAR '+' /* Mark unit as redefinition to suppress warning message */ -#define DEFAULTPAGER "more" /* Default pager program */ +#define DEFAULTPAGER "/usr/bin/pager" /* Default pager program */ #define DEFAULTLOCALE "en_US" /* Default locale */ diff -Nru units-2.16/debian/patches/reproducible.patch units-2.19/debian/patches/reproducible.patch --- units-2.16/debian/patches/reproducible.patch 2015-04-11 22:10:52.000000000 +0000 +++ units-2.19/debian/patches/reproducible.patch 2019-06-01 11:51:07.000000000 +0000 @@ -6,12 +6,12 @@ --- a/texi2man +++ b/texi2man -@@ -21,7 +21,7 @@ +@@ -23,7 +23,7 @@ $args=($#ARGV < 0) ? "stdin" : "@ARGV"; printf(".\\\"Do not edit this file. It was created from %s\n", $args); --printf(".\\\"using texi2man version %s on %s", $version, `date`); -+printf(".\\\"using texi2man version", $version); +-printf(".\\\"using %s version %s on %s", $thisprog, $version, `date`); ++printf(".\\\"using %s version %s", $thisprog, $version); while(<>) { diff -Nru units-2.16/debian/patches/units_cur-python3.patch units-2.19/debian/patches/units_cur-python3.patch --- units-2.16/debian/patches/units_cur-python3.patch 2017-10-26 09:37:03.000000000 +0000 +++ units-2.19/debian/patches/units_cur-python3.patch 2018-10-22 08:12:15.000000000 +0000 @@ -3,7 +3,7 @@ --- a/configure.ac +++ b/configure.ac -@@ -157,7 +157,7 @@ +@@ -174,7 +174,7 @@ fi diff -Nru units-2.16/debian/rules units-2.19/debian/rules --- units-2.16/debian/rules 2017-06-19 20:51:20.000000000 +0000 +++ units-2.19/debian/rules 2018-07-04 06:51:16.000000000 +0000 @@ -5,3 +5,10 @@ %: dh $@ + +override_dh_auto_configure: + dh_auto_configure -- --sharedstatedir=/var/lib + +override_dh_md5sums: +# There’s no point in measuring variable state + dh_md5sums -X var/lib diff -Nru units-2.16/debian/units.lintian-overrides units-2.19/debian/units.lintian-overrides --- units-2.16/debian/units.lintian-overrides 1970-01-01 00:00:00.000000000 +0000 +++ units-2.19/debian/units.lintian-overrides 2018-07-04 06:53:43.000000000 +0000 @@ -0,0 +1,2 @@ +# This file is intended to be overwritten +units: file-missing-in-md5sums var/lib/units/currency.units diff -Nru units-2.16/debian/units.maintscript units-2.19/debian/units.maintscript --- units-2.16/debian/units.maintscript 1970-01-01 00:00:00.000000000 +0000 +++ units-2.19/debian/units.maintscript 2018-07-08 21:35:29.000000000 +0000 @@ -0,0 +1 @@ +rm_conffile /etc/cron.daily/units 2.17-3~ diff -Nru units-2.16/definitions.units units-2.19/definitions.units --- units-2.16/definitions.units 2017-10-31 00:03:42.000000000 +0000 +++ units-2.19/definitions.units 2019-05-30 01:18:07.000000000 +0000 @@ -2,9 +2,9 @@ # This file is the units database for use with GNU units, a units conversion # program by Adrian Mariano adrianm@gnu.org # -# October 2017 Version 2.19 +# May 2019 Version 3.04 # -# Copyright (C) 1996-2002, 2004-2017 +# Copyright (C) 1996-2002, 2004-2019 # Free Software Foundation, Inc # # This program is free software; you can redistribute it and/or modify @@ -26,15 +26,16 @@ # # Improvements and corrections are welcome. # -# Fundamental constants in this file are the 2014 CODATA recommended values. +# Fundamental constants in this file are the 2018 CODATA recommended values. # # Most units data was drawn from # 1. NIST Special Publication 811, Guide for the # Use of the International System of Units (SI). -# Barry N. Taylor. 1995 +# Barry N. Taylor. 2008 +# https://www.nist.gov/pml/special-publication-811 # 2. CRC Handbook of Chemistry and Physics 70th edition # 3. Oxford English Dictionary -# 4. Websters New Universal Unabridged Dictionary +# 4. Webster's New Universal Unabridged Dictionary # 5. Units of Measure by Stephen Dresner # 6. A Dictionary of English Weights and Measures by Ronald Zupko # 7. British Weights and Measures by Ronald Zupko @@ -67,8 +68,12 @@ # 23. CRC Handbook of Chemistry and Physics, 96th edition # 24. Dictionary of Scientific Units, 6th ed. H.G. Jerrard and D.B. # McNeill. 1992 -# -# Thanks to Jeff Conrad for assistance in ferreting out unit definitions. +# 25. NIST Special Publication 330, The International System of +# Units (SI). ed. Barry N. Taylor and Ambler Thompson. 2008 +# https://www.nist.gov/pml/special-publication-330 +# 26. BIPM Brochure, The International System of Units (SI). +# 9th ed., 2019 +# https://www.bipm.org/en/publications/si-brochure/ # ########################################################################### # @@ -76,9 +81,6 @@ # If your country's local units are missing and you are willing to supply # them, please send me a list. # -# I added shoe size information but I'm not convinced that it's correct. -# If you know anything about shoe sizes please contact me. -# ########################################################################### ########################################################################### @@ -125,6 +127,20 @@ !set UNITS_ENGLISH US # Default setting for English units +!set UNITS_SYSTEM default # Set a default value + +!varnot UNITS_SYSTEM si emu esu gaussian gauss default +!message Unknown unit system given with -u or UNITS_SYSTEM environment variable +!message Valid systems: si, emu, esu, gauss[ian] +!message Using SI +!prompt (SI) +!endvar + +!var UNITS_SYSTEM si +!message SI units selected +!prompt (SI) +!endvar + ########################################################################### # # # Primitive units. Any unit defined to contain a '!' character is a # @@ -136,42 +152,250 @@ # # SI units # - -kg ! # Mass of the international prototype -kilogram kg - -s ! # Duration of 9192631770 periods of the radiation -second s # corresponding to the transition between the two hyperfine - # levels of the ground state of the cesium-133 atom - -m ! # Length of the path traveled by light in a vacuum -meter m # during 1|299792458 seconds. Originally meant to be - # 1e-7 of the length along a meridian from the equator - # to a pole. - -A ! # The current which produces a force of 2e-7 N/m between two -ampere A # infinitely long wires that are 1 meter apart -amp ampere - -cd ! # Luminous intensity in a given direction of a source which -candela cd # emits monochromatic radiation at 540e12 Hz with radiant - # intensity 1|683 W/steradian. (This differs from radiant - # intensity (W/sr) in that it is adjusted for human - # perceptual dependence on wavelength. The frequency of - # 540e12 Hz (yellow) is where human perception is most - # efficient.) - -mol ! # The amount of substance of a system which contains as many -mole mol # elementary entities as there are atoms in 0.012 kg of - # carbon 12. The elementary entities must be specified and - # may be atoms, molecules, ions, electrons, or other - # particles or groups of particles. It is understood that - # unbound atoms of carbon 12, at rest and in the ground - # state, are referred to. - -K ! # 1|273.16 of the thermodynamic temperature of the triple -kelvin K # point of water - +# On 20 May 2019, the SI was revised to define the units by fixing the +# values of physical constants that depend on those units. +# +# https://www.nist.gov/si-redefinition/ +# +# The BIPM--the International Bureau of Weights and Measures--provides a +# succinct description of the new SI in its Concise Summary: +# +# https://www.bipm.org/utils/common/pdf/si-brochure/SI-Brochure-9-concise-EN.pdf +# +# The SI is the system of units in which: +# +# * the unperturbed ground state hyperfine transition frequency of the +# caesium 133 atom is delta nu_Cs = 9 192 631 770 Hz, +# * the speed of light in vacuum, c, is 299 792 458 m/s, +# * the Planck constant, h, is 6.626 070 15 * 10^-34 J s, +# * the elementary charge, e, is 1.602 176 634 * 10^-19 C, +# * the Boltzmann constant, k, is 1.380 649 * 10^-23 J/K, +# * the Avogadro constant, N_A, is 6.022 140 76 * 10^23 mol^-1, +# * the luminous efficacy of monochromatic radiation of frequency +# 540 * 10^12 Hz, K_cd, is 683 lm/W, +# +# where the hertz, joule, coulomb, lumen, and watt, with unit symbols Hz, +# J, C, lm, and W, respectively, are related to the units second, metre, +# kilogram, ampere, kelvin, mole, and candela, with unit symbols s, m, kg, +# A, K, mol, and cd, respectively, according to Hz = s^–1, J = kg m^2 s^–2, +# C = A s, lm = cd m^2 m^–2 = cd sr, and W = kg m^2 s^–3. +# +# These definitions specify the exact numerical value of each constant when +# its value is expressed in the corresponding SI unit. By fixing the exact +# numerical value the unit becomes defined, since the product of the +# numerical value and the unit has to equal the value of the constant, +# which is invariant. +# +# The defining constants have been chosen such that, when taken together, +# their units cover all of the units of the SI. In general, there is no +# one-to-one correspondence between the defining constants and the SI base +# units. Any SI unit is a product of powers of these seven constants and a +# dimensionless factor. +# +# Until 2018, the SI was defined in terms of base units and derived units. +# These categories are no longer essential in the SI, but they are maintained +# in view of their convenience and widespread use. They are arguably more +# intuitive than the new definitions. (They are also essential to the +# operation of GNU units.) The definitions of the base units, which follow +# from the definition of the SI in terms of the seven defining constants, are +# given below. +# + +s ! # The second, symbol s, is the SI unit of time. It is defined +second s # by taking the fixed numerical value of the unperturbed + # ground-state hyperfine transition frequency of the + # cesium-133 atom to be 9 192 1631 770 when expressed in the + # unit Hz, which is equal to 1/s. + # + # This definition is a restatement of the previous one, the + # duration of 9192631770 periods of the radiation corresponding + # to the cesium-133 transition. + +c 299792458 m/s # speed of light in vacuum (exact) + +m ! # The metre, symbol m, is the SI unit of length. It is +meter m # defined by taking the fixed numerical value of the speed +metre m # of light in vacuum, c, to be 299 792 458 when expressed in + # units of m/s. + # + # This definition is a rewording of the previous one and is + # equivalent to defining the meter as the distance light + # travels in 1|299792458 seconds. The meter was originally + # intended to be 1e-7 of the length along a meridian from the + # equator to a pole. + +h 6.62607015e-34 J s # Planck constant (exact) + +kg ! # The kilogram, symbol kg, is the SI unit of mass. It is +kilogram kg # defined by taking the fixed numerical value of the Planck + # constant, h, to be 6.626 070 15 * 10^-34 when expressed in + # the unit J s which is equal to kg m^2 / s. + # + # One advantage of fixing h to define the kilogram is that this + # affects constants used to define the ampere. If the kg were + # defined by directly fixing the mass of something, then h + # would be subject to error. + # + # The previous definition of the kilogram was the mass of the + # international prototype kilogram. The kilogram was the last + # unit whose definition relied on reference to an artifact. + # + # It is not obvious what this new definition means, or + # intuitively how fixing Planck's constant defines the + # kilogram. To define the kilogram we need to give the mass + # of some reference in kilograms. Previously the prototype in + # France served as this reference, and it weighed exactly 1 + # kg. But the reference can have any weight as long as you + # know the weight of the reference. The new definition uses + # the "mass" of a photon, or more accurately, the mass + # equivalent of the energy of a photon. The energy of a + # photon depends on its frequency. If you pick a frequency, + # f, then the energy of the photon is hf, and hence the mass + # equivalent is hf/c^2. If we reduce this expression using + # the constant defined values for h and c the result is a + # value in kilograms for the mass-equivalent of a photon of + # frequency f, which can therefore define the size of the + # kilogram. + # + # For more on the relationship between mass an Planck's + # constant: + # + # https://www.nist.gov/si-redefinition/kilogram-mass-and-plancks-constant + # This definition may still seem rather abstract: you can't + # place a "kilogram of radiation" on one side of a balance. + # Metrologists realize the kilogram using a Kibble Balance, a + # device which relates mechanical energy to electrical energy + # and can measure mass with extreme accuracy if h is known. + # + # For more on the Kibble Balance see + # + # https://www.nist.gov/si-redefinition/kilogram-kibble-balance + # https://en.wikipedia.org/wiki/Kibble_balance + +boltzmann 1.380649e-23 J/K # Boltzmann constant (exact) +k boltzmann + +K ! # The kelvin, symbol K, is the SI unit of thermodynamic +kelvin K # temperature. It is defined by taking the fixed numerical + # value of the Boltzmann constant, k, to be 1.380 649 * 10^-23 + # when expressed in the unit J/K, which is equal to + # kg m^2/s^2 K. + # + # The boltzmann constant establishes the relationship between + # energy and temperature. The average thermal energy carried + # by each degree of freedom is kT/2. A monatomic ideal gas + # has three degrees of freedom corresponding to the three + # spatial directions, which means its thermal energy is + # (3/2) k T. + # + # The previous definition of the kelvin was based on the + # triple point of water. The change in the definition of the + # kelvin will not have much effect on measurement practice. + # Practical temperature calibration makes use of two scales, + # the International Temperature Scale of 1990 (ITS-90), which + # covers the range of 0.65 K to 1357.77K and the Provisional + # Low Temperature Scale of 2000 (PLTS-2000), which covers the + # range of 0.9 mK to 1 K. + # https://www.bipm.org/en/committees/cc/cct/publications-cc.html + # + # The ITS-90 contains 17 reference points including things + # like the triple point of hydrogen (13.8033 K) or the + # freezing point of gold (1337.33 K), and of course the triple + # point of water. The PLTS-2000 specifies four reference + # points, all based on properties of helium-3. + # + # The redefinition of the kelvin will not affect the values of + # these reference points, which have been determined by + # primary thermometry, using thermometers that rely only on + # relationships that allow temperature to be calculated + # directly without using any unknown quantities. Examples + # include acoustic thermometers, which measure the speed of + # sound in a gas, or electronic thermometers, which measure + # tiny voltage fluctuations in resistors. Both variables + # depend directly on temperature. + +e 1.602176634e-19 C # electron charge (exact) + +A ! # The ampere, symbol A, is the SI unit of electric current. +ampere A # It is defined by taking the fixed numerical value of the +amp ampere # elementary charge, e, to be 1.602 176 634 * 10^-19 when + # expressed in the unit C, which is equal to A*s. + # + # The previous definition was the current which produces a + # force of 2e-7 N/m between two infinitely long wires a meter + # apart. This definition was difficult to realize accurately. + # + # The ampere is actually realized by establishing the volt and + # the ohm, since A = V / ohm. These measurements can be done + # using the Josephson effect and the quantum Hall effect, + # which accurately measure voltage and resistance, respectively, + # with reference to two fixed constants, the Josephson + # constant, K_J=2e/h and the von Klitzing constant, R_K=h/e^2. + # Under the previous SI system, these constants had official + # fixed values, defined in 1990. This created a situation + # where the standard values for the volt and ohm were in some + # sense outside of SI because they depended primarily on + # constants different from the ones used to define SI. After + # the revision, since e and h have exact definitions, the + # Josephson and von Klitzing constants will also have exact + # definitions that derive from SI instead of the conventional + # 1990 values. + # + # In fact we know that there is a small offset between the + # conventional values of the electrical units based on the + # conventional 1990 values and the SI values. The new + # definition, which brings the practical electrical units back + # into SI, will lead to a one time change of +0.1ppm for + # voltage values and +0.02ppm for resistance values. + # + # The previous definition resulted in fixed exact values for + # the vacuum permeability (mu0), the impedance of free space + # (Z0), the vacuum permittivity (epsilon0), and the Coulomb + # constant. With the new definition, these four values are + # subject to experimental error. + +avogadro 6.02214076e23 / mol # Size of a mole (exact) +N_A avogadro + +mol ! # The mole, symbol mol, is the SI unit of amount of +mole mol # substance. One mole contains exactly 6.022 140 76 * 10^23 + # elementary entities. This number is the fixed numerical + # value of the Avogadro constant, N_A, when expressed in the + # unit 1/mol and is called the Avogadro number. The amount of + # substance, symbol n, of a system is a measure of the number + # of specified elementary entities. An elementary entity may + # be an atom, a molecule, an ion, an electron, any other + # particle or specified group of particles. + # + # The atomic mass unit (u) is defined as 1/12 the mass of + # carbon-12. Previously the mole was defined so that a mole + # of carbon-12 weighed exactly 12g, or N_A u = 1 g/mol + # exactly. This relationship is now an experimental, + # approximate relationship. + # + # To determine the size of the mole, researchers used spheres + # of very pure silicon-28 that weighed a kilogram. They + # measured the molar mass of Si-28 using mass spectrometry and + # used X-ray diffraction interferometry to determine the + # spacing of the silicon atoms in the sphere. Using the + # sphere's volume it was then possible to determine the number + # of silicon atoms in the sphere, and hence determine the + # Avogadro constant. The results of this experiment were used to + # define N_A, which is henceforth a fixed, unchanging quantity. + +cd ! # The candela, symbol cd, is the SI unit of luminous intensity +candela cd # in a given direction. It is defined by taking the fixed + # numerical value of the luminous efficacy of monochromatic + # radiation of the frequency 540e12 Hz to be 683 when + # expressed in the unit lumen/watt, which is equal to + # cd sr/W, or cd sr s^3/kg m^2 + # + # This definition is a rewording of the previous definition. + # Luminous intensity differs from radiant intensity (W/sr) in + # that it is adjusted for human perceptual dependence on + # wavelength. The frequency of 540e12 Hz (yellow; + # wavelength approximately 555 nm in vacuum) is where human + # perception is most efficient. # # The radian and steradian are defined as dimensionless primitive units. # The radian is equal to m/m and the steradian to m^2/m^2 so these units are @@ -190,18 +414,20 @@ # sphere # -# Some primitive non-SI units +# A primitive non-SI unit # -US$ ! # The US dollar is chosen arbitrarily to be the primitive - # unit of money. - bit ! # Basic unit of information (entropy). The entropy in bits # of a random variable over a finite alphabet is defined # to be the sum of -p(i)*log2(p(i)) over the alphabet where # p(i) is the probability that the random variable takes # on the value i. +# +# Currency: the primitive unit of currency is defined in currency.units. +# It is usually the US$ or the euro, but it is user selectable. +# + ########################################################################### # # # Prefixes (longer names must come first) # @@ -476,7 +702,7 @@ F farad weber V s # magnetic flux Wb weber -henry Wb/A # inductance +henry V s / A # inductance H henry tesla Wb/m^2 # magnetic flux density T tesla @@ -493,7 +719,6 @@ AREA LENGTH^2 VOLUME LENGTH^3 MASS kilogram -CURRENT ampere AMOUNT mole ANGLE radian SOLID_ANGLE steradian @@ -501,11 +726,6 @@ FORCE newton PRESSURE FORCE / AREA STRESS FORCE / AREA -CHARGE coulomb -CAPACITANCE farad -RESISTANCE ohm -CONDUCTANCE siemens -INDUCTANCE henry FREQUENCY hertz VELOCITY LENGTH / TIME ACCELERATION VELOCITY / TIME @@ -513,7 +733,31 @@ LINEAR_DENSITY MASS / LENGTH VISCOSITY FORCE TIME / AREA KINEMATIC_VISCOSITY VISCOSITY / DENSITY - +CURRENT ampere +CHARGE coulomb +CAPACITANCE farad +RESISTANCE ohm +CONDUCTANCE siemens +INDUCTANCE henry +E_FIELD ELECTRIC_POTENTIAL / LENGTH +B_FIELD tesla +# The D and H fields are related to the E and B fields by factors of +# epsilon and mu respectively, so their units can be found by +# multiplying/dividing by the epsilon0 and mu0. The more complex +# definitions below make it possible to use D_FIELD and E_FIELD to +# convert between SI and CGS units for these dimensions. +D_FIELD E_FIELD epsilon0 mu0_SI c^2 F / m +H_FIELD B_FIELD / (mu0/mu0_SI) (H/m) +ELECTRIC_DIPOLE_MOMENT C m +MAGNETIC_DIPOLE_MOMENT J / T +POLARIZATION ELECTRIC_DIPOLE_MOMENT / VOLUME +MAGNETIZATION MAGNETIC_DIPOLE_MOMENT / VOLUME +ELECTRIC_POTENTIAL volt +VOLTAGE ELECTRIC_POTENTIAL +E_FLUX E_FIELD AREA +D_FLUX D_FIELD AREA +B_FLUX B_FIELD AREA +H_FLUX H_FIELD AREA # # units derived easily from SI units @@ -558,7 +802,16 @@ # reference to common x-ray lines, either # the K-alpha 1 line of copper or the # same line of molybdenum. -angstromstar 1.00001495 angstrom # Defined by JA Bearden in 1965 +angstromstar 1.00001495 angstrom # Defined by JA Bearden in 1965 to replace + # the X unit. The wavelength of the + # tungsten K alpha1 line was defined as + # exactly 0.20901 angstrom star, with the + # valule chosen to try to make the new + # unit close to the angstrom. +silicon_d220 1.920155716e-10 m # Silicon lattice spacing +siliconlattice sqrt(8) silicon_d220# Silicon lattice parameter, (a), the side + # length of the unit cell for the diamond + # centered cubic structure of silicon. fermi 1e-15 m # Convenient for describing nuclear sizes # Nuclear radius is from 1 to 10 fermis barn 1e-28 m^2 # Used to measure cross section for @@ -867,58 +1120,59 @@ # Basic constants pi 3.14159265358979323846 -c 2.99792458e8 m/s # speed of light in vacuum (exact) light c -mu0 4 pi 1e-7 H/m # permeability of vacuum (exact) -epsilon0 1/mu0 c^2 # permittivity of vacuum (exact) -energy c^2 # convert mass to energy -e 1.6021766208e-19 C # electron charge -h 4.135667662e-15 eV s # Planck constant +mu0_SI 2 alpha h / e^2 c # Vacuum magnetic permeability +mu0 mu0_SI # Gets overridden in CGS modes +epsilon0 1/mu0 c^2 # Vacuum electric permittivity +Z0 mu0 c # Free space impedance +energy c^2 # Convert mass to energy hbar h / 2 pi spin hbar -G 6.67408e-11 N m^2 / kg^2 # Newtonian gravitational constant - # This is the NIST 2006 value. - # The relative uncertainty on this - # is 1e-4. -coulombconst 1/4 pi epsilon0 # listed as "k" sometimes +G 6.67430e-11 N m^2 / kg^2 # Newtonian gravitational constant +coulombconst 1/4 pi epsilon0 # Listed as k or k_C sometimes +k_C coulombconst # Physico-chemical constants -atomicmassunit 1.660539040e-27 kg # atomic mass unit (defined to be -u atomicmassunit # 1|12 of the mass of carbon 12) -amu atomicmassunit +atomicmassunit 1.66053906660e-27 kg # Unified atomic mass unit, defined as +u atomicmassunit # 1|12 of the mass of carbon 12. +amu atomicmassunit # The relationship N_A u = 1 g/mol +dalton u # is approximately, but not exactly +Da dalton # true (with the 2019 SI). + # Previously the mole was defined to + # make this relationship exact. amu_chem 1.66026e-27 kg # 1|16 of the weighted average mass of # the 3 naturally occuring neutral # isotopes of oxygen amu_phys 1.65981e-27 kg # 1|16 of the mass of a neutral # oxygen 16 atom -dalton u # Maybe this should be amu_chem? -avogadro grams/amu mol # size of a mole -N_A avogadro -gasconstant k N_A # molar gas constant +gasconstant k N_A # Molar gas constant (exact) R gasconstant -boltzmann 1.38064852e-23 J/K # Boltzmann constant -k boltzmann kboltzmann boltzmann molarvolume mol R stdtemp / atm # Volume occupied by one mole of an # ideal gas at STP. loschmidt avogadro mol / molarvolume # Molecules per cubic meter of an # ideal gas at STP. Loschmidt did # work similar to Avogadro. +molarvolume_si N_A siliconlattice^3 / 8 # Volume of a mole of crystalline + # silicon. The unit cell contains 8 + # silicon atoms and has a side + # length of siliconlattice. stefanboltzmann pi^2 k^4 / 60 hbar^3 c^2 # The power per area radiated by a sigma stefanboltzmann # blackbody at temperature T is - # given by sigma T^4. -wiendisplacement 2.8977729e-3 m K # Wien's Displacement Law gives the - # frequency at which the the Planck - # spectrum has maximum intensity. - # The relation is lambda T = b where - # lambda is wavelength, T is - # temperature and b is the Wien + # given by sigma T^4. (exact) +wiendisplacement (h c/k)/4.9651142317442763 # Wien's Displacement Law gives + # the frequency at which the the + # Planck spectrum has maximum + # intensity. The relation is lambda + # T = b where lambda is wavelength, + # T is temperature and b is the Wien # displacement. This relation is # used to determine the temperature - # of stars. + # of stars. The constant is the + # solution to x=5(1-exp(-x)). (exact) K_J90 483597.9 GHz/V # Direct measurement of the volt is difficult. Until -K_J 483597.8525 GHz/V # recently, laboratories kept Weston cadmium cells as +K_J 2e/h # recently, laboratories kept Weston cadmium cells as # a reference, but they could drift. In 1987 the # CGPM officially recommended the use of the # Josephson effect as a laboratory representation of @@ -928,12 +1182,12 @@ # with a frequency that depends on the potential # applied across the superconductors. This frequency # can be very accurately measured. The Josephson - # constant K_J, which is equal to 2e/h, relates the - # measured frequency to the potential. Two values - # given, the conventional (exact) value from 1990 and - # the current CODATA measured value. + # constant K_J relates the measured frequency to the + # potential. Two values given, the conventional + # (exact) value from 1990, which was used until the + # 2019 SI revision, and the current exact value. R_K90 25812.807 ohm # Measurement of the ohm also presents difficulties. -R_K 25812.8074555 ohm # The old approach involved maintaining resistances +R_K h/e^2 # The old approach involved maintaining resistances # that were subject to drift. The new standard is # based on the Hall effect. When a current carrying # ribbon is placed in a magnetic field, a potential @@ -944,9 +1198,25 @@ # in discrete jumps when the magnetic field is very # large and the temperature very low. This enables # accurate realization of the resistance h/e^2 in the - # lab. Two values given, the conventional (exact) - # value from 1990 and the current CODATA measured - # value. + # lab. The 1990 value was an exact conventional + # value used until the SI revision in 2019. This value + # did not agree with measurements. The new value + # is exact. + +# The 2019 update to SI gives exact definitions for R_K and K_J. Previously +# the electromagnetic units were realized using the 1990 conventional values +# for these constants, and as a result, the standard definitions were in some +# sense outside of SI. The revision corrects this problem. The definitions +# below give the 1990 conventional values for the electromagnetic units in +# terms of 2019 SI. + +ampere90 (K_J90 R_K90 / K_J R_K) A +coulomb90 (K_J90 R_K90 / K_J R_K) C +farad90 (R_K90/R_K) F +henry90 (R_K/R_K90) H +ohm90 (R_K/R_K90) ohm +volt90 (K_J90/K_J) V +watt90 (K_J90^2 R_K90 / K_J^2 R_K) W # Various conventional values @@ -986,7 +1256,7 @@ # Atomic constants -Rinfinity 10973731.568539 /m # The wavelengths of a spectral series +Rinfinity 10973731.568160 /m # The wavelengths of a spectral series R_H 10967760 /m # can be expressed as # 1/lambda = R (1/m^2 - 1/n^2). # where R is a number that various @@ -996,56 +1266,54 @@ # approaches Rinfinity, which can be # computed from # m_e c alpha^2 / 2 h - # with a loss of 4 digits + # with a loss of 2 digits # of precision. -alpha 7.2973525664e-3 # The fine structure constant was +alpha 7.2973525693e-3 # The fine structure constant was # introduced to explain fine # structure visible in spectral - # lines. It can be computed from - # mu0 c e^2 / 2 h - # with a loss of 3 digits precision - # and loss of precision in derived - # values which use alpha. + # lines. bohrradius alpha / 4 pi Rinfinity prout 185.5 keV # nuclear binding energy equal to 1|12 # binding energy of the deuteron +conductancequantum 2 e^2 / h + # Planck constants -planckmass 2.17651e-8 kg # sqrt(hbar c / G) +planckmass sqrt(hbar c / G) m_P planckmass plancktime hbar / planckmass c^2 t_P plancktime plancklength plancktime c l_P plancklength +plancktemperature hbar / k plancktime +T_P plancktemperature # Particle radius -electronradius (1/4 pi epsilon0) e^2 / electronmass c^2 # Classical -deuteronchargeradius 2.1413e-15 m +electronradius coulombconst e^2 / electronmass c^2 # Classical +deuteronchargeradius 2.12799e-15 m protonchargeradius 0.8751e-15 m # Masses of elementary particles -electronmass 5.48579909070e-4 u +electronmass 5.48579909065e-4 u m_e electronmass -protonmass 1.007276466879 u -m_p protonmass -neutronmass 1.00866491588 u -m_n neutronmass -muonmass 0.1134289257 u +muonmass 0.1134289259 u m_mu muonmass -deuteronmass 2.013553212745 u -m_d deuteronmass -alphaparticlemass 4.001506179127 u -m_alpha alphaparticlemass -taumass 1.90749 u +taumass 1.90754 u m_tau taumass -tritonmass 3.01550071632 u -m_t tritonmass -helionmass 3.01493224673 u -m_h helionmass - - +protonmass 1.007276466621 u +m_p protonmass +neutronmass 1.00866491595 u +m_n neutronmass +deuteronmass 2.013553212745 u # Nucleus of deuterium, one +m_d deuteronmass # proton and one neutron +alphaparticlemass 4.001506179127 u # Nucleus of He, two protons +m_alpha alphaparticlemass # and two neutrons +tritonmass 3.01550071621 u # Nucleius of H3, one proton +m_t tritonmass # and two neutrons +helionmass 3.014932247175 u # Nucleus of He3, two protons +m_h helionmass # and one neutron # particle wavelengths: the compton wavelength of a particle is # defined as h / m c where m is the mass of the particle. @@ -1056,21 +1324,39 @@ lambda_C,p protonwavelength neutronwavelength h / m_n c lambda_C,n neutronwavelength +muonwavelength h / m_mu c +lambda_C,mu muonwavelength -# Magnetic moments - -bohrmagneton e hbar / 2 electronmass -mu_B bohrmagneton -nuclearmagneton e hbar / 2 protonmass -mu_N nuclearmagneton -mu_mu -4.49044826e-26 J/T # Muon magnetic moment -mu_p 1.4106067873e-26 J/T # Proton magnetic moment -mu_e -928.4764620e-26 J/T # Electron magnetic moment -mu_n -0.96623650e-26 J/T # Neutron magnetic moment -mu_d 0.4330735040e-26 J/T # Deuteron magnetic moment -mu_t 1.504609503e-26 J/T # Triton magnetic moment -mu_h -1.074617522e-26 J/T # Helion magnetic moment - +# The g-factor or dimensionless magnetic moment is a quantity that +# characterizes the magnetic moment of a particle. The electron g-factor is +# one of the most precisely measured values in physics, with a relative +# uncertainty of 1.7e-13. + +g_d 0.8574382338 # Deuteron g-factor +g_e -2.00231930436256 # Electron g-factor +g_h -4.255250615 # Helion g-factor +g_mu -2.0023318418 # Muon g-factor +g_n -3.82608545 # Neutron g-factor +g_p 5.5856946893 # Proton g-factor +g_t 5.957924931 # Triton g-factor + +# Magnetic moments (derived from the more accurate g-factors) +# +# The magnetic moment is g * mu_ref * spin where in most cases +# the reference is the nuclear magneton, and all of the particles +# except the deuteron have spin 1/2. + +bohrmagneton e hbar / 2 electronmass # Reference magnetic moment for +mu_B bohrmagneton # the electron +nuclearmagneton e hbar / 2 protonmass # Convenient reference magnetic +mu_N nuclearmagneton # moment for heavy particles +mu_e g_e mu_B / 2 # Electron spin magnet moment +mu_mu g_mu e hbar / 4 muonmass # Muon spin magnetic moment +mu_p g_p mu_N / 2 # Proton magnetic moment +mu_n g_n mu_N / 2 # Neutron magnetic moment +mu_t g_t mu_N / 2 # Triton magnetic moment +mu_d g_d mu_N # Deuteron magnetic moment, spin 1 +mu_h g_h mu_N / 2 # Helion magnetic moment # # Units derived from physical constants @@ -1100,7 +1386,7 @@ # heliocentric parallax of 1 # arcsec (derived from parallax # second). A distant object with - # paralax theta will be about + # parallax theta will be about # (arcsec/theta) parsecs from the # sun (using the approximation # that tan(theta) = theta). @@ -1148,13 +1434,11 @@ glug gram force s^2 / cm # Mass which is accelerated at # 1 cm/s^2 by 1 gram force darcy centipoise cm^2 / s atm # Measures permeability to fluid flow. - # One darcy is the permeability of a # medium that allows a flow of cc/s # of a liquid of centipoise viscosity # under a pressure gradient of # atm/cm. Named for H. Darcy. - mobileohm cm / dyn s # mobile ohm, measure of mechanical # mobility mechanicalohm dyn s / cm # mechanical resistance @@ -1165,61 +1449,243 @@ rayl dyn s / cm^3 # Specific acoustical resistance eotvos 1e-9 Gal/cm # Change in gravitational acceleration # over horizontal distance +# +# Electromagnetic CGS Units +# +# For measuring electromagnetic quantities in SI, we introduce the new base +# dimension of current, define the ampere to measure current, and derive the +# other electromagnetic units from the ampere. With the CGS units one approach +# is to use the basic equations of electromagnetism to define units that +# eliminate constants from those equations. Coulomb's law has the form +# +# F = k_C q1 q2 / r^2 +# +# where k_C is the Coulomb constant equal to 1|4 pi epsilon0 in SI units. +# Ampere's force law takes the form +# +# dF/dl = 2 k_A I1 I2 / r +# +# where k_A is the ampere constant. In the CGS system we force either k_C or +# k_A to 1 which then defines either a unit for charge or a unit for current. +# The other unit then becomes a derived unit. When k_C is 1 the ESU system +# results. When k_A is 1 the EMU system results. Note that these parameters +# are not independent of each other: Maxwell's equations indicate that +# +# k_C / k_A = c^2 +# +# where c is the speed of light. +# +# One more choice is needed to define a complete system. Using Coulomb's law +# we define the electric field as the force per unit charge +# +# E = k_C 1 / r^2. +# +# But what about the magnetic field? It is derived from Ampere's law but we +# have the option of adding a proportionality constant, k_B, that may have +# dimensions: +# +# B = 2 k_A k_B I / r +# +# We can choose k_B = 1, which is done in the SI, ESU and EMU systems. But if +# instead we give k_B units of length/time then the magnetic field has +# the same units as the electric field. This choice leads to the Gaussian +# system. +# +# The relations above are used to determine the dimensions, but the units are +# derived from the base units of CGS, not directly from those formulas. We +# will use the notation [unit] to refer to the dimension of the unit in +# brackets. This same process gives rise to the SI units such as the tesla, +# which is defined by +# +# B = 2 +# +# References: +# +# Classical Electrodynamics by John David Jackson, 3rd edition. +# Cardarelli, Francois. 1999. Scientific Unit Conversion. 2nd ed. Trans. +# M.J. Shields. London: Springer-Verlag. ISBN 1-85233-043-0 +# +# +# All of these systems result in electromagnetic units that involve the square +# roots of the centimeter and gram. This requires a change in the primitive +# units. +# + +!var UNITS_SYSTEM esu emu gaussian gauss +sqrt_cm ! +sqrt_centimeter sqrt_cm ++m 100 sqrt_cm^2 +sqrt_g ! +sqrt_gram sqrt_g ++kg kilo sqrt_g^2 +!endvar + +# Electrostatic CGS (ESU) +# +# This system uses the statcoulomb as the fundamental unit of charge, with +# derived units that parallel the conventional terminology but use the stat- +# prefix. The statcoulomb is designed by setting k_C=1, which means +# +# dyne = statcoulomb^2 / cm^2. +# +# The statcoulomb is also called the franklin or esu. +# +# The ESU system was specified by a committee report in 1873 and rarely used. + +statcoulomb 10 coulomb cm / s c # Charge such that two charges +esu statcoulomb # of 1 statC separated by 1 cm +statcoul statcoulomb # exert a force of 1 dyne +statC statcoulomb +stC statcoulomb +franklin statcoulomb +Fr franklin + +!var UNITS_SYSTEM esu +!message CGS-ESU units selected +!prompt (ESU) ++statcoulomb sqrt(dyne) cm ++A 0.1 statamp c/(cm/s) ++mu0 1/c^2 ++coulombconst 1 +!endvar -# Electromagnetic units derived from the abampere +statampere statcoulomb / s +statamp statampere +statA statampere +stA statampere +statvolt dyne cm / statamp sec +statV statvolt +stV statvolt +statfarad statamp sec / statvolt +statF statfarad +stF statfarad +cmcapacitance statfarad +stathenry statvolt sec / statamp +statH stathenry +stH stathenry +statohm statvolt / statamp +stohm statohm +statmho /statohm +stmho statmho +statweber statvolt sec +statWb statweber +stWb statweber +stattesla statWb/cm^2 # Defined by analogy with SI; rarely +statT stattesla # if ever used +stT stattesla +debye 1e-10 statC angstrom # unit of electrical dipole moment +helmholtz debye/angstrom^2 # Dipole moment per area +jar 1000 statfarad # approx capacitance of Leyden jar + +# Electromagnetic CGS (EMU) +# +# The abampere is the fundamental unit of this system, with the derived units +# using the ab- prefix. The dimensions of the abampere are defined by assuming +# that k_A=1, which +# +# [dyne / cm] = [2 abampere^2 / cm] +# +# where the brackets indicate taking the dimension of the unit in base units +# and discarding any constant factors. This results in the definition from +# base CGS units of: +# +# abampere = sqrt(dyne). +# +# The abampere is also called the biot. The magnetic field unit (the gauss) +# follows from the assumption that k_B=1, which means +# +# B = 2 I / r, +# +# and hence the dimensions of the gauss are given by +# +# [gauss] = [2 abampere / cm] +# +# or rewriting in terms of the base units +# +# gauss = abampere / cm. +# +# The definition given below is different because it is in a form that +# gives a valid reduction for SI and ESU and still gives the correct +# result in EMU. (It can be derived from Faraday's law.) +# +# The EMU system was developed by Gauss and Weber and formalized as a system in +# a committee report by the British Association for the Advancement of Science +# in 1873. abampere 10 A # Current which produces a force of abamp abampere # 2 dyne/cm between two infinitely aA abampere # long wires that are 1 cm apart -biot aA # alternative name for abamp +abA abampere +biot abampere Bi biot + +!var UNITS_SYSTEM emu +!message CGS-EMU units selected +!prompt (EMU) ++abampere sqrt(dyne) ++A 0.1 abamp ++mu0 1 ++coulombconst c^2 +!endvar + abcoulomb abamp sec abcoul abcoulomb +abC abcoulomb abfarad abampere sec / abvolt +abF abfarad abhenry abvolt sec / abamp +abH abhenry abvolt dyne cm / abamp sec +abV abvolt abohm abvolt / abamp abmho /abohm -gauss abvolt sec / cm^2 -Gs gauss -maxwell abvolt sec # Also called the "line" +gauss abvolt sec / cm^2 # The magnetic field 2 cm from a wire +Gs gauss # carrying a current of 1 abampere +maxwell gauss cm^2 # Also called the "line" Mx maxwell -oersted gauss / mu0 -Oe oersted +oersted gauss / mu0 # From the relation H = B / mu +Oe oersted gilbert gauss cm / mu0 Gb gilbert Gi gilbert -unitpole 4 pi maxwell +unitpole 4 pi maxwell # unit magnetic pole emu erg/gauss # "electro-magnetic unit", a measure of # magnetic moment, often used as emu/cm^3 # to specify magnetic moment density. -# Gaussian system: electromagnetic units derived from statampere. +# Electromagnetic CGS (Gaussian) # -# Note that the Gaussian units are often used in such a way that Coulomb's law -# has the form F= q1 * q2 / r^2. The constant 1|4*pi*epsilon0 is incorporated -# into the units. From this, we can get the relation force=charge^2/dist^2. -# This means that the simplification esu^2 = dyne cm^2 can be used to simplify -# units in the Gaussian system, with the curious result that capacitance can be -# measured in cm, resistance in sec/cm, and inductance in sec^2/cm. These -# units are given the names statfarad, statohm and stathenry below. - -statampere 10 A cm / s c -statamp statampere -statvolt dyne cm / statamp sec -statcoulomb statamp s -esu statcoulomb -statcoul statcoulomb -statfarad statamp sec / statvolt -cmcapacitance statfarad -stathenry statvolt sec / statamp -statohm statvolt / statamp -statmho /statohm -statmaxwell statvolt sec -franklin statcoulomb -debye 1e-18 statcoul cm # unit of electrical dipole moment -helmholtz debye/angstrom^2 # Dipole moment per area -jar 1000 statfarad # approx capacitance of Leyden jar +# The Gaussian system uses the statcoulomb and statamp from the ESU system +# derived by setting k_C=1, but it defines the magnetic field unit differently +# by taking k_B=c instead of k_B=1. As noted above, k_C and k_A are not +# independent. With k_C=1 we must have k_A=c^-2. This results in the magnetic +# field unit, the gauss, having dimensions give by: +# +# [gauss] = [2 (c^-2) c statamp / cm] = [statamp / c cm] +# +# We then define the gauss using base CGS units to obtain +# +# gauss = statamp / ((cm/s) cm) = statcoulomb / cm^2. +# +# Note that this definition happens to give the same result as the definition +# for the EMU system, so the definitions of the gauss are consistent. +# +# This definition gives the same dimensions for the E and B fields and was also +# known as the "symmetric system". This system was proposed by Hertz in 1888. + +!var UNITS_SYSTEM gaussian gauss +!message CGS-Gaussian units selected +!prompt (Gaussian) ++statcoulomb sqrt(dyne) cm ++A 0.1 statamp c/(cm/s) ++mu0 1 ++epsilon0 1 ++coulombconst 1 # The gauss is the B field produced ++gauss statcoulomb / cm^2 # 1 cm from a wire carrying a current ++weber 1e8 maxwell # of 0.5*(c/(cm/s)) stA = 1.5e10 stA ++bohrmagneton e hbar / 2 electronmass c ++nuclearmagneton e hbar / 2 protonmass c +!endvar # # Some historical electromagnetic units @@ -1631,7 +2097,7 @@ # is close to 19 eclipse years.) # The eclipse will occur about # 120 degrees west of the - # preceeding one because the + # preceding one because the # saros is not an even number of # days. After 3 saros, an # eclipse will occur at @@ -1701,7 +2167,7 @@ # 32.5 years. islamicmonth 1|12 islamicyear # They have 29 day and 30 day months. -# The Hewbrew year is also based on lunar months, but synchronized to the solar +# The Hebrew year is also based on lunar months, but synchronized to the solar # calendar. The months vary irregularly between 29 and 30 days in length, and # the years likewise vary. The regular year is 353, 354, or 355 days long. To # keep up with the solar calendar, a leap month of 30 days is inserted every @@ -1787,8 +2253,9 @@ au astronomicalunit # ephemeris for the above described # astronomical unit. (See the NASA # site listed above.) -solarmass 1.9891e30 kg -sunmass solarmass +GMsun 1.32712440018e20 m^3 / s^2 # heliocentric gravitational constant +solarmass GMsun/G # with uncertainty 8e9 is known more +sunmass solarmass # accurately than G. sundist 1.0000010178 au # mean earth-sun distance @@ -2054,26 +2521,39 @@ # 13.553962 - -# # The Hartree system of atomic units, derived from fundamental units -# of mass (of electron), action (planck's constant), charge, and -# the coulomb constant. +# of mass (of electron), action (Planck's constant), charge, and +# the Coulomb constant. +# The Hartree energy can be derived from m_e, e, hbar, and coulombconst by +# hartree = coulombconst^2 m_e e^4 / hbar^2 +# but due to correlations between the measurements for m_e and coulombconst +# this results in a significant loss of precision. So we use an alternate +# equivalent definition for the hartree and derive then use energy instead +# of the Coulomb constant to derive the other units. This method retains the +# precision. + +hartree 2 rydberg # Approximate electric potential energy of + # the hydrogen atom in its ground state, + # and approximately twice its ionization + # energy. # Fundamental units atomicmass electronmass atomiccharge e atomicaction hbar +atomicenergy hartree -# derived units (Warning: accuracy is lost from deriving them this way) +# Derived units -atomiclength bohrradius -atomictime hbar^3/coulombconst^2 atomicmass e^4 # Period of first - # bohr orbit -atomicvelocity atomiclength / atomictime -atomicenergy hbar / atomictime -hartree atomicenergy +atomicvelocity sqrt(atomicenergy / atomicmass) +atomictime atomicaction / atomicenergy +atomiclength atomicvelocity atomictime +atomicforce atomicenergy / atomiclength +atomicmomentum atomicenergy / atomicvelocity +atomiccurrent atomiccharge / atomictime +atomicpotential atomicenergy / atomiccharge # electrical potential +atomicEfield atomicpotential / atomiclength # # These thermal units treat entropy as charge, from [5] @@ -2380,9 +2860,17 @@ jeroboam 2 magnum rehoboam 3 magnum methuselah 4 magnum +imperialbottle 4 magnum salmanazar 6 magnum balthazar 8 magnum nebuchadnezzar 10 magnum +solomon 12 magnum +melchior 12 magnum +sovereign 17.5 magnum +primat 18 magnum +goliath 18 magnum +melchizedek 20 magnum +midas 20 magnum # The wine glass doesn't seem to have an official standard, but the same value # is suggested by several organization. @@ -2685,7 +3173,6 @@ # alternate spellings -metre meter gramme gram litre liter dioptre diopter @@ -2758,7 +3245,7 @@ legaltbsp legaltablespoon # Scoop size. Ice cream scoops in the US are marked with numbers -# indicating the number of scoops requird to fill a US quart. +# indicating the number of scoops required to fill a US quart. scoop(n) units=[1;cup] domain=[4,100] range=[0.04,1] \ 32 usfloz / n ; 32 usfloz / scoop @@ -2914,7 +3401,7 @@ # # But I'm using equation (3) which is credited to Starzak and Peacock, # "Water activity coefficient in aqueous solutions of sucrose--A comprehensive -# data analyzis. Zuckerindustrie, 122, 380-387. (I couldn't find this +# data analysis. Zuckerindustrie, 122, 380-387. (I couldn't find this # document.) # # Note that the range of validity is uncertain, but answers are in agreement @@ -2939,8 +3426,8 @@ # sc(x) (x / 342.3) / (( x/342.3) + (100-x)/18.02); \ # 100 sc 342.3|18.02 / (sc (342.3|18.02-1)+1) # -# Here is a simplfied version of this equation where the temperature of boiling -# water has been fixed at 100 degrees Celcius and the argument is now the +# Here is a simplified version of this equation where the temperature of boiling +# water has been fixed at 100 degrees Celsius and the argument is now the # concentration (brix). # # sugar_bpe(x) ((1+ 0.48851085 * sc(x)^2 (1+ -1.0038 sc(x) + -0.24653 sc(x)^2)) \ @@ -2992,7 +3479,7 @@ # not possible to convert to a nested function, so you're stuck retyping the # absolute temperature in Kelvins to convert to celsius or Fahrenheit. To # prevent this we supply definitions that build in the temperature conversion -# and produce results in the Fahrenheit and Celcius scales. So using these +# and produce results in the Fahrenheit and Celsius scales. So using these # measures, to convert 46 degrees Baume to a Fahrenheit boiling point: # # You have: baume(45) @@ -3065,6 +3552,423 @@ apidegree(x) units=[1;g/cm^3] domain=[-131.5,) range=[0,) \ 141.5 g/cm^3 / (x+131.5) ; \ 141.5 (g/cm^3) / apidegree + (-131.5) +# +# Average densities of various woods (dried) +# Data from The Wood Database https://www.wood-database.com +# + +# North American Hardwoods + +wood_cherry 35 lb/ft^3 +wood_redoak 44 lb/ft^3 +wood_whiteoak 47 lb/ft^3 +wood_blackwalnut 38 lb/ft^3 +wood_walnut wood_blackwalnut +wood_birch 43 lb/ft^3 +wood_hardmaple 44 lb/ft^3 + +wood_bigleafmaple 34 lb/ft^3 +wood_boxeldermaple 30 lb/ft^3 +wood_redmaple 38 lb/ft^3 +wood_silvermaple 33 lb/ft^3 +wood_stripedmaple 32 lb/ft^3 +wood_softmaple (wood_bigleafmaple \ + + wood_boxeldermaple \ + + wood_redmaple \ + + wood_silvermaple \ + + wood_stripedmaple) / 5 +wood_poplar 29 lb/ft^3 +wood_beech 45 lb/ft^3 + +# North American Softwoods + +wood_jeffreypine 28 lb/ft^3 +wood_ocotepine 44 lb/ft^3 +wood_ponderosapine 28 lb/ft^3 + +wood_loblollypine 35 lb/ft^3 +wood_longleafpine 41 lb/ft^3 +wood_shortleafpine 35 lb/ft^3 +wood_slashpine 41 lb/ft^3 +wood_yellowpine (wood_loblollypine \ + + wood_longleafpine \ + + wood_shortleafpine \ + + wood_slashpine) / 4 +wood_redpine 34 lb/ft^3 + +wood_easternwhitepine 25 lb/ft^3 +wood_westernwhitepine 27 lb/ft^3 +wood_whitepine (wood_easternwhitepine + wood_westernwhitepine) / 2 + +wood_douglasfir 32 lb/ft^3 + +wood_blackspruce 28 lb/ft^3 +wood_engelmannspruce 24 lb/ft^3 +wood_redspruce 27 lb/ft^3 +wood_sitkaspruce 27 lb/ft^3 +wood_whitespruce 27 lb/ft^3 +wood_spruce (wood_blackspruce \ + + wood_engelmannspruce \ + + wood_redspruce \ + + wood_sitkaspruce \ + + wood_whitespruce) / 5 + +# Other woods + +wood_basswood 26 lb/ft^3 +wood_balsa 9 lb/ft^3 +wood_ebony_gaboon 60 lb/ft^3 +wood_ebony_macassar 70 lb/ft^3 +wood_mahogany 37 lb/ft^3 # True (Honduran) mahogany, + # Swietenia macrophylla +wood_teak 41 lb/ft^3 +wood_rosewood_brazilian 52 lb/ft^3 +wood_rosewood_honduran 64 lb/ft^3 +wood_rosewood_indian 52 lb/ft^3 +wood_cocobolo 69 lb/ft^3 +wood_bubinga 56 lb/ft^3 +wood_zebrawood 50 lb/ft^3 +wood_koa 38 lb/ft^3 +wood_snakewood 75.7 lb/ft^3 +wood_lignumvitae 78.5 lb/ft^3 +wood_blackwood 79.3 lb/ft^3 +wood_blackironwood 84.5 lb/ft^3 # Krugiodendron ferreum, listed + # in database as the heaviest wood + +# +# Modulus of elasticity of selected woods. +# Data from The Wood Database https://www.wood-database.com +# + +# North American Hardwoods + +wood_mod_beech 1.720e6 lbf/in^2 +wood_mod_birchyellow 2.010e6 lbf/in^2 +wood_mod_birch wood_mod_birchyellow +wood_mod_cherry 1.490e6 lbf/in^2 +wood_mod_hardmaple 1.830e6 lbf/in^2 + +wood_mod_bigleafmaple 1.450e6 lbf/in^2 +wood_mod_boxeldermaple 1.050e6 lbf/in^2 +wood_mod_redmaple 1.640e6 lbf/in^2 +wood_mod_silvermaple 1.140e6 lbf/in^2 +wood_mod_softmaple (wood_mod_bigleafmaple \ + + wood_mod_boxeldermaple \ + + wood_mod_redmaple \ + + wood_mod_silvermaple) / 4 + +wood_mod_redoak 1.761e6 lbf/in^2 +wood_mod_whiteoak 1.762e6 lbf/in^2 +wood_mod_poplar 1.580e6 lbf/in^2 +wood_mod_blackwalnut 1.680e6 lbf/in^2 +wood_mod_walnut wood_mod_blackwalnut + +# North American Softwoods + +wood_mod_jeffreypine 1.240e6 lbf/in^2 +wood_mod_ocotepine 2.209e6 lbf/in^2 +wood_mod_ponderosapine 1.290e6 lbf/in^2 + +wood_mod_loblollypine 1.790e6 lbf/in^2 +wood_mod_longleafpine 1.980e6 lbf/in^2 +wood_mod_shortleafpine 1.750e6 lbf/in^2 +wood_mod_slashpine 1.980e6 lbf/in^2 +wood_mod_yellowpine (wood_mod_loblollypine \ + + wood_mod_longleafpine \ + + wood_mod_shortleafpine \ + + wood_mod_slashpine) / 4 + +wood_mod_redpine 1.630e6 lbf/in^2 + +wood_mod_easternwhitepine 1.240e6 lbf/in^2 +wood_mod_westernwhitepine 1.460e6 lbf/in^2 +wood_mod_whitepine (wood_mod_easternwhitepine + \ + wood_mod_westernwhitepine) / 2 + +wood_mod_douglasfir 1.765e6 lbf/in^2 + +wood_mod_blackspruce 1.523e6 lbf/in^2 +wood_mod_englemannspruce 1.369e6 lbf/in^2 +wood_mod_redspruce 1.560e6 lbf/in^2 +wood_mod_sitkaspruce 1.600e6 lbf/in^2 +wood_mod_whitespruce 1.315e6 lbf/in^2 +wood_mod_spruce (wood_mod_blackspruce \ + + wood_mod_englemannspruce \ + + wood_mod_redspruce + wood_mod_sitkaspruce \ + + wood_mod_whitespruce) / 5 + +# Other woods + +wood_mod_balsa 0.538e6 lbf/in^2 +wood_mod_basswood 1.460e6 lbf/in^2 +wood_mod_blackwood 2.603e6 lbf/in^2 # African, Dalbergia melanoxylon +wood_mod_bubinga 2.670e6 lbf/in^2 +wood_mod_cocobolo 2.712e6 lbf/in^2 +wood_mod_ebony_gaboon 2.449e6 lbf/in^2 +wood_mod_ebony_macassar 2.515e6 lbf/in^2 +wood_mod_blackironwood 2.966e6 lbf/in^2 # Krugiodendron ferreum +wood_mod_koa 1.503e6 lbf/in^2 +wood_mod_lignumvitae 2.043e6 lbf/in^2 +wood_mod_mahogany 1.458e6 lbf/in^2 # True (Honduran) mahogany, + # Swietenia macrophylla +wood_mod_rosewood_brazilian 2.020e6 lbf/in^2 +wood_mod_rosewood_honduran 3.190e6 lbf/in^2 +wood_mod_rosewood_indian 1.668e6 lbf/in^2 +wood_mod_snakewood 3.364e6 lbf/in^2 +wood_mod_teak 1.781e6 lbf/in^2 +wood_mod_zebrawood 2.374e6 lbf/in^2 + +# +# Area of countries and other regions. This is the "total area" which +# includes land and water areas within international boundaries and +# coastlines. Data from January, 2019. +# +# https://en.wikipedia.org/wiki/List_of_countries_and_dependencies_by_area +# https://www.cia.gov/library/publications/the-world-factbook) + +area_russia 17098246 km^2 +area_antarctica 14000000 km^2 +area_canada 9984670 km^2 +area_china 9596961 km^2 +area_unitedstates 9525067 km^2 # includes only the 50 states +area_us area_unitedstates # and District of Columbia +area_brazil 8515767 km^2 +area_australia 7692024 km^2 +area_europeanunion 4475757 km^2 +area_eu area_europeanunion +area_india 3287263 km^2 +area_argentina 2780400 km^2 +area_kazakhstan 2724900 km^2 +area_algeria 2381741 km^2 +area_drcongo 2344858 km^2 +area_greenland 2166086 km^2 +area_saudiarabia 2149690 km^2 +area_mexico 1964375 km^2 +area_indonesia 1910931 km^2 +area_sudan 1861484 km^2 +area_libya 1759540 km^2 +area_iran 1648195 km^2 +area_mongolia 1564110 km^2 +area_peru 1285216 km^2 +area_chad 1284000 km^2 +area_niger 1267000 km^2 +area_angola 1246700 km^2 +area_mali 1240192 km^2 +area_southafrica 1221037 km^2 +area_colombia 1141748 km^2 +area_ethiopia 1104300 km^2 +area_bolivia 1098581 km^2 +area_mauritania 1030700 km^2 +area_egypt 1002450 km^2 +area_tanzania 945087 km^2 +area_nigeria 923768 km^2 +area_venezuela 916445 km^2 +area_pakistan 881912 km^2 +area_namibia 825615 km^2 +area_mozambique 801590 km^2 +area_turkey 783562 km^2 +area_chile 756102 km^2 +area_zambia 752612 km^2 +area_myanmar 676578 km^2 +area_afghanistan 652230 km^2 +area_southsudan 644329 km^2 +area_france 640679 km^2 +area_somalia 637657 km^2 +area_centralafrica 622984 km^2 +area_ukraine 603500 km^2 +area_crimea 27000 km^2 # occupied by Russia; included in + # (Encyclopedia Britannica) +area_madagascar 587041 km^2 +area_botswana 581730 km^2 +area_kenya 580367 km^2 +area_yemen 527968 km^2 +area_thailand 513120 km^2 +area_spain 505992 km^2 +area_turkmenistan 488100 km^2 +area_cameroon 475422 km^2 +area_papuanewguinea 462840 km^2 +area_sweden 450295 km^2 +area_uzbekistan 447400 km^2 +area_morocco 446550 km^2 +area_iraq 438317 km^2 +area_paraguay 406752 km^2 +area_zimbabwe 390757 km^2 +area_japan 377973 km^2 +area_germany 357114 km^2 +area_congorepublic 342000 km^2 +area_finland 338424 km^2 +area_vietnam 331212 km^2 +area_malaysia 330803 km^2 +area_norway 323802 km^2 +area_ivorycoast 322463 km^2 +area_poland 312696 km^2 +area_oman 309500 km^2 +area_italy 301339 km^2 +area_philippines 300000 km^2 +area_ecuador 276841 km^2 +area_burkinafaso 274222 km^2 +area_newzealand 270467 km^2 +area_gabon 267668 km^2 +area_westernsahara 266000 km^2 +area_guinea 245857 km^2 +area_uk 242495 km^2 +area_uganda 241550 km^2 +area_ghana 238533 km^2 +area_romania 238397 km^2 +area_laos 236800 km^2 +area_guyana 214969 km^2 +area_belarus 207600 km^2 +area_kyrgyzstan 199951 km^2 +area_senegal 196722 km^2 +area_syria 185180 km^2 +area_golanheights 1150 km^2 # occupied by Israel; included in + # Syria (Encyclopedia Britannica) +area_cambodia 181035 km^2 +area_uruguay 176215 km^2 +area_somaliland 176120 km^2 +area_suriname 163820 km^2 +area_tunisia 163610 km^2 +area_bangladesh 147570 km^2 +area_nepal 147181 km^2 +area_tajikistan 143100 km^2 +area_greece 131990 km^2 +area_nicaragua 130373 km^2 +area_northkorea 120540 km^2 +area_malawi 118484 km^2 +area_eritrea 117600 km^2 +area_benin 114763 km^2 +area_honduras 112492 km^2 +area_liberia 111369 km^2 +area_bulgaria 110879 km^2 +area_cuba 109884 km^2 +area_guatemala 108889 km^2 +area_iceland 103000 km^2 +area_southkorea 100210 km^2 +area_hungary 93028 km^2 +area_portugal 92090 km^2 +area_jordan 89342 km^2 +area_serbia 88361 km^2 +area_azerbaijan 86600 km^2 +area_austria 83871 km^2 +area_uae 83600 km^2 +area_czechrepublic 78865 km^2 +area_panama 75417 km^2 +area_sierraleone 71740 km^2 +area_ireland 70273 km^2 +area_georgia 69700 km^2 +area_srilanka 65610 km^2 +area_lithuania 65300 km^2 +area_latvia 64559 km^2 +area_togo 56785 km^2 +area_croatia 56594 km^2 +area_bosnia 51209 km^2 +area_costarica 51100 km^2 +area_slovakia 49037 km^2 +area_dominicanrepublic 48671 km^2 +area_estonia 45227 km^2 +area_denmark 43094 km^2 +area_netherlands 41850 km^2 +area_switzerland 41284 km^2 +area_bhutan 38394 km^2 +area_taiwan 36193 km^2 +area_guineabissau 36125 km^2 +area_moldova 33846 km^2 +area_gelgium 30528 km^2 +area_lesotho 30355 km^2 +area_armenia 29743 km^2 +area_solomonislands 28896 km^2 +area_albania 28748 km^2 +area_equitorialguinea 28051 km^2 +area_burundi 27834 km^2 +area_haiti 27750 km^2 +area_rwanda 26338 km^2 +area_northmacedonia 25713 km^2 +area_djibouti 23200 km^2 +area_belize 22966 km^2 +area_elsalvador 21041 km^2 +area_israel 20770 km^2 +area_slovenia 20273 km^2 +area_fiji 18272 km^2 +area_kuwait 17818 km^2 +area_eswatini 17364 km^2 +area_easttimor 14919 km^2 +area_bahamas 13943 km^2 +area_montenegro 13812 km^2 +area_vanatu 12189 km^2 +area_qatar 11586 km^2 +area_gambia 11295 km^2 +area_jamaica 10991 km^2 +area_kosovo 10887 km^2 +area_lebanon 10452 km^2 +area_cyprus 9251 km^2 +area_puertorico 9104 km^2 # United States territory; not included + # in United States area +area_westbank 5860 km^2 # (CIA World Factbook) +area_hongkong 2755 km^2 +area_luxembourg 2586 km^2 +area_singapore 716 km^2 +area_gazastrip 360 km^2 # (CIA World Factbook) +area_liechtenstein 160 km^2 +area_monaco 2.02 km^2 +area_vaticancity 0.44 km^2 + +# +# Area of the individual United States +# +# https://en.wikipedia.org/wiki/List_of_U.S._states_and_territories_by_area +# + +area_alaska 1723337 km^2 +area_texas 695662 km^2 +area_california 423972 km^2 +area_montana 380831 km^2 +area_newmexico 314917 km^2 +area_arizona 295234 km^2 +area_nevada 286380 km^2 +area_colorado 269601 km^2 +area_oregon 254799 km^2 +area_wyoming 253335 km^2 +area_michigan 250487 km^2 +area_minnesota 225163 km^2 +area_utah 219882 km^2 +area_idaho 216443 km^2 +area_kansas 213100 km^2 +area_nebraska 200330 km^2 +area_southdakota 199729 km^2 +area_washington 184661 km^2 +area_northdakota 183108 km^2 +area_oklahoma 181037 km^2 +area_missouri 180540 km^2 +area_florida 170312 km^2 +area_wisconsin 169635 km^2 +area_georgia_us 153910 km^2 +area_illinois 149995 km^2 +area_iowa 145746 km^2 +area_newyork 141297 km^2 +area_northcarolina 139391 km^2 +area_arkansas 137732 km^2 +area_alabama 135767 km^2 +area_louisiana 135659 km^2 +area_mississippi 125438 km^2 +area_pennsylvania 119280 km^2 +area_ohio 116098 km^2 +area_virginia 110787 km^2 +area_tennessee 109153 km^2 +area_kentucky 104656 km^2 +area_indiana 94326 km^2 +area_maine 91633 km^2 +area_southcarolina 82933 km^2 +area_westvirginia 62756 km^2 +area_maryland 32131 km^2 +area_hawaii 28313 km^2 +area_massachusetts 27336 km^2 +area_vermont 24906 km^2 +area_newhampshire 24214 km^2 +area_newjersey 22591 km^2 +area_connecticut 14357 km^2 +area_delaware 6446 km^2 +area_rhodeisland 4001 km^2 +area_districtofcolumbia 177 km^2 # # Units derived from imperial system @@ -3187,7 +4091,10 @@ calorie_fifteen cal_15 calorie_20 4.18190 J # Energy to go from 19.5 to 20.5 degC cal_20 calorie_20 -calorie_twenty calorie_20 +calorie_twenty calorie_20 +calorie_4 4.204 J # Energy to go from 3.5 to 4.5 degC +cal_4 calorie_4 +calorie_four calorie_4 cal_mean 4.19002 J # 1|100 energy to go from 0 to 100 degC Calorie kilocalorie # the food Calorie thermie 1e6 cal_15 # Heat required to raise the @@ -3201,10 +4108,13 @@ btu_IT cal_IT lb degF / gram K btu_th cal_th lb degF / gram K btu_mean cal_mean lb degF / gram K +btu_15 cal_15 lb degF / gram K +btu_ISO 1055.06 J # Exact, rounded ISO definition based + # on the IT calorie quad quadrillion btu -ECtherm 1.05506e8 J # Exact definition, close to 1e5 btu -UStherm 1.054804e8 J # Exact definition +ECtherm 1e5 btu_ISO # Exact definition +UStherm 1.054804e8 J # Exact definition, therm UStherm # Water latent heat from [23] @@ -3507,6 +4417,8 @@ littleboy hiroshima ivyking 500 kiloton tnt # most powerful fission bomb castlebravo 15 megaton tnt # most powerful US test +tsarbomba 50 megaton tnt # most powerful test ever: USSR, + # 30 October 1961 b53bomb 9 megaton tnt # http://rarehistoricalphotos.com/gadget-first-atomic-bomb/ trinity 18 kiloton tnt # July 16, 1945 @@ -4101,13 +5013,14 @@ # generally given in US$. # +unitedstatesdollar US$ usdollar US$ $ dollar mark germanymark -bolivar venezuelabolivar -venezuelanbolivarfuerte venezuelabolivar -bolivarfuerte bolivar # The currency was revalued by -oldbolivar 1|1000 bolivar # a factor of 1000. +#bolivar venezuelabolivar # Not all databases are +#venezuelabolivarfuerte 1e-5 bolivar # supplying these +#bolivarfuerte 1e-5 bolivar # The currency was revalued +#oldbolivar 1|1000 bolivarfuerte # twice peseta spainpeseta rand southafricarand escudo portugalescudo @@ -4132,7 +5045,7 @@ icelandkróna icelandkrona polandzłoty polandzloty tongapa’anga tongapa'anga -venezuelabolívar venezuelabolivar +#venezuelabolívar venezuelabolivar vietnamđồng vietnamdong mongoliatögrög mongoliatugrik sãotomé&príncipedobra saotome&principedobra @@ -5305,7 +6218,7 @@ plf lb / foot # pounds per linear foot # -# Compatibility units with unix version +# Compatibility units with Unix version # pa Pa @@ -5755,6 +6668,45 @@ doppelzentner 2 zentner pfund 500 g +# The klafter, which was used in central Europe, was derived from the span of +# outstretched arms. +# +# https://en.wikipedia.org/wiki/Obsolete_Austrian_units_of_measurement +# https://www.llv.li/files/abi/klafter-m2-en.pdf + +austriaklafter 1.89648384 m # Exact definition, 23 July 1871 +austriafoot 1|6 austriaklafter +prussiaklafter 1.88 m +prussiafoot 1|6 prussiaklafter +bavariaklafter 1.751155 m +bavariafoot 1|6 bavariaklafter +hesseklafter 2.5 m +hessefoot 1|6 hesseklafter +switzerlandklafter metricklafter +switzerlandfoot 1|6 switzerlandklafter +swissklafter switzerlandklafter +swissfoot 1|6 swissklafter +metricklafter 1.8 m + +austriayoke 8 austriaklafter * 200 austriaklafter + +liechtensteinsquareklafter 3.596652 m^2 # Used until 2017 to measure land area +liechtensteinklafter sqrt(liechtensteinsquareklafter) + +# The klafter was also used to measure volume of wood, generally being a stack +# of wood one klafter wide, one klafter long, with logs 3 feet (half a klafter) +# in length + +prussiawoodklafter 0.5 prussiaklafter^3 +austriawoodklafter 0.5 austriaklafter^3 +festmeter m^3 # modern measure of wood, solid cube +raummeter 0.7 festmeter # Air space between the logs, stacked +schuettraummeter 0.65 raummeter # A cubic meter volume of split and cut +schüttraummeter schuettraummeter# firewood in a loose, unordered + # pile, not stacked. This is called + # "tipped". + + # # Swedish (Sweden) pre-metric units of 1739. # The metric system was adopted in 1878. @@ -6072,7 +7024,7 @@ # liters, but then says the amphora is a # cubic Roman foot. This gives a value for the # sextarius of 0.540 liters. And the - # encyclopedia Brittanica lists 0.53 liters for + # encyclopedia Britannica lists 0.53 liters for # this unit. Both [7] and [11], which were # written by scholars of weights and measures, # give the value of 35.4 cubic inches. @@ -6357,6 +7309,9 @@ # U+2150- 1|7 For some reason these characters are getting # U+2151- 1|9 flagged as invalid UTF8. # U+2152- 1|10 +#⅐- 1|7 # fails under MacOS +#⅑- 1|9 # fails under MacOS +#⅒- 1|10 # fails under MacOS ℯ exp(1) # U+212F, base of natural log µ- micro # micro sign U+00B5 μ- micro # small mu U+03BC @@ -6398,10 +7353,10 @@ ₩ southkoreawon ₪ israelnewshekel ₤ lira -₺ turkeylira +# ₺ turkeylira # fails under MacOS ₨ rupee # unofficial legacy rupee sign -₹ indiarupee # official rupee sign -؋ afghanafghani +# ₹ indiarupee # official rupee sign # MacOS fail +#؋ afghanafghani # fails under MacOS ฿ thailandbaht ₡ elsalvadorcolon # Also costaricacolon ₣ francefranc @@ -6412,13 +7367,13 @@ ₮ mongoliatugrik ₯ greecedrachma ₱ philippinepeso -₲ paraguayguarani -₴ ukrainehryvnia -₵ ghanacedi -₸ kazakhstantenge -₼ azerbaijanmanat -₽ russiaruble -₾ georgialari +# ₲ paraguayguarani # fails under MacOS +#₴ ukrainehryvnia # fails under MacOS +#₵ ghanacedi # fails under MacOS +#₸ kazakhstantenge # fails under MacOS +#₼ azerbaijanmanat # fails under MacOS +#₽ russiaruble # fails under MacOS +#₾ georgialari # fails under MacOS ﷼ iranrial ﹩ $ ¢ ¢ @@ -6427,7 +7382,7 @@ ₩ ₩ # -# Square unicode symbols starting at U+3371 +# Square Unicode symbols starting at U+3371 # ㍱ hPa @@ -6554,7 +7509,7 @@ ############################################################################ # -# The following units were in the unix units database but do not appear in +# The following units were in the Unix units database but do not appear in # this file: # # wey used for cheese, salt and other goods. Measured mass or diff -Nru units-2.16/INSTALL units-2.19/INSTALL --- units-2.16/INSTALL 2005-04-24 18:14:54.000000000 +0000 +++ units-2.19/INSTALL 2018-08-28 22:12:24.000000000 +0000 @@ -1,181 +1,370 @@ +Installation Instructions +************************* + +Copyright (C) 1994-1996, 1999-2002, 2004-2012 Free Software Foundation, +Inc. + + Copying and distribution of this file, with or without modification, +are permitted in any medium without royalty provided the copyright +notice and this notice are preserved. This file is offered as-is, +without warranty of any kind. + Basic Installation ================== - These are generic installation instructions. + Briefly, the shell commands './configure; make; make install' should +configure, build, and install this package. The following +more-detailed instructions are generic; see the 'README' file for +instructions specific to this package. Some packages provide this +'INSTALL' file but do not implement all of the features documented +below. The lack of an optional feature in a given package is not +necessarily a bug. More recommendations for GNU packages can be found +in *note Makefile Conventions: (standards)Makefile Conventions. - The `configure' shell script attempts to guess correct values for + The 'configure' shell script attempts to guess correct values for various system-dependent variables used during compilation. It uses -those values to create a `Makefile' in each directory of the package. -It may also create one or more `.h' files containing system-dependent -definitions. Finally, it creates a shell script `config.status' that -you can run in the future to recreate the current configuration, a file -`config.cache' that saves the results of its tests to speed up -reconfiguring, and a file `config.log' containing compiler output -(useful mainly for debugging `configure'). +those values to create a 'Makefile' in each directory of the package. +It may also create one or more '.h' files containing system-dependent +definitions. Finally, it creates a shell script 'config.status' that +you can run in the future to recreate the current configuration, and a +file 'config.log' containing compiler output (useful mainly for +debugging 'configure'). + + It can also use an optional file (typically called 'config.cache' +and enabled with '--cache-file=config.cache' or simply '-C') that saves +the results of its tests to speed up reconfiguring. Caching is +disabled by default to prevent problems with accidental use of stale +cache files. If you need to do unusual things to compile the package, please try -to figure out how `configure' could check whether to do them, and mail -diffs or instructions to the address given in the `README' so they can -be considered for the next release. If at some point `config.cache' -contains results you don't want to keep, you may remove or edit it. - - The file `configure.in' is used to create `configure' by a program -called `autoconf'. You only need `configure.in' if you want to change -it or regenerate `configure' using a newer version of `autoconf'. - -The simplest way to compile this package is: - - 1. `cd' to the directory containing the package's source code and type - `./configure' to configure the package for your system. If you're - using `csh' on an old version of System V, you might need to type - `sh ./configure' instead to prevent `csh' from trying to execute - `configure' itself. - - Running `configure' takes awhile. While running, it prints some - messages telling which features it is checking for. - - 2. Type `make' to compile the package. - - 3. Optionally, type `make check' to run any self-tests that come with - the package. - - 4. Type `make install' to install the programs and any data files and - documentation. - - 5. You can remove the program binaries and object files from the - source code directory by typing `make clean'. To also remove the - files that `configure' created (so you can compile the package for - a different kind of computer), type `make distclean'. There is - also a `make maintainer-clean' target, but that is intended mainly +to figure out how 'configure' could check whether to do them, and mail +diffs or instructions to the address given in the 'README' so they can +be considered for the next release. If you are using the cache, and at +some point 'config.cache' contains results you don't want to keep, you +may remove or edit it. + + The file 'configure.ac' (or 'configure.in') is used to create +'configure' by a program called 'autoconf'. You need 'configure.ac' if +you want to change it or regenerate 'configure' using a newer version +of 'autoconf'. + + The simplest way to compile this package is: + + 1. 'cd' to the directory containing the package's source code and type + './configure' to configure the package for your system. + + Running 'configure' might take a while. While running, it prints + some messages telling which features it is checking for. + + 2. Type 'make' to compile the package. + + 3. Optionally, type 'make check' to run any self-tests that come with + the package, generally using the just-built uninstalled binaries. + + 4. Type 'make install' to install the programs and any data files and + documentation. When installing into a prefix owned by root, it is + recommended that the package be configured and built as a regular + user, and only the 'make install' phase executed with root + privileges. + + 5. Optionally, type 'make installcheck' to repeat any self-tests, but + this time using the binaries in their final installed location. + This target does not install anything. Running this target as a + regular user, particularly if the prior 'make install' required + root privileges, verifies that the installation completed + correctly. + + 6. You can remove the program binaries and object files from the + source code directory by typing 'make clean'. To also remove the + files that 'configure' created (so you can compile the package for + a different kind of computer), type 'make distclean'. There is + also a 'make maintainer-clean' target, but that is intended mainly for the package's developers. If you use it, you may have to get all sorts of other programs in order to regenerate files that came with the distribution. + 7. Often, you can also type 'make uninstall' to remove the installed + files again. In practice, not all packages have tested that + uninstallation works correctly, even though it is required by the + GNU Coding Standards. + + 8. Some packages, particularly those that use Automake, provide `make + distcheck', which can by used by developers to test that all other + targets like 'make install' and 'make uninstall' work correctly. + This target is generally not run by end users. + Compilers and Options ===================== Some systems require unusual options for compilation or linking that -the `configure' script does not know about. You can give `configure' -initial values for variables by setting them in the environment. Using -a Bourne-compatible shell, you can do that on the command line like -this: - CC=c89 CFLAGS=-O2 LIBS=-lposix ./configure +the 'configure' script does not know about. Run './configure --help' +for details on some of the pertinent environment variables. -Or on systems that have the `env' program, you can do it like this: - env CPPFLAGS=-I/usr/local/include LDFLAGS=-s ./configure + You can give 'configure' initial values for configuration parameters +by setting variables in the command line or in the environment. Here +is an example: + + ./configure CC=c99 CFLAGS=-g LIBS=-lposix + + *Note Defining Variables::, for more details. Compiling For Multiple Architectures ==================================== You can compile the package for more than one kind of computer at the same time, by placing the object files for each architecture in their -own directory. To do this, you must use a version of `make' that -supports the `VPATH' variable, such as GNU `make'. `cd' to the +own directory. To do this, you can use GNU 'make'. 'cd' to the directory where you want the object files and executables to go and run -the `configure' script. `configure' automatically checks for the -source code in the directory that `configure' is in and in `..'. +the 'configure' script. 'configure' automatically checks for the +source code in the directory that 'configure' is in and in '..'. This +is known as a "VPATH" build. + + With a non-GNU 'make', it is safer to compile the package for one +architecture at a time in the source code directory. After you have +installed the package for one architecture, use 'make distclean' before +reconfiguring for another architecture. + + On MacOS X 10.5 and later systems, you can create libraries and +executables that work on multiple system types--known as "fat" or +"universal" binaries--by specifying multiple '-arch' options to the +compiler but only a single '-arch' option to the preprocessor. Like +this: - If you have to use a `make' that does not supports the `VPATH' -variable, you have to compile the package for one architecture at a time -in the source code directory. After you have installed the package for -one architecture, use `make distclean' before reconfiguring for another -architecture. + ./configure CC="gcc -arch i386 -arch x86_64 -arch ppc -arch ppc64" \ + CXX="g++ -arch i386 -arch x86_64 -arch ppc -arch ppc64" \ + CPP="gcc -E" CXXCPP="g++ -E" + + This is not guaranteed to produce working output in all cases, you +may have to build one architecture at a time and combine the results +using the 'lipo' tool if you have problems. Installation Names ================== - By default, `make install' will install the package's files in -`/usr/local/bin', `/usr/local/man', etc. You can specify an -installation prefix other than `/usr/local' by giving `configure' the -option `--prefix=PATH'. + By default, 'make install' installs the package's commands under +'/usr/local/bin', include files under '/usr/local/include', etc. You +can specify an installation prefix other than '/usr/local' by giving +'configure' the option '--prefix=PREFIX', where PREFIX must be an +absolute file name. You can specify separate installation prefixes for architecture-specific files and architecture-independent files. If you -give `configure' the option `--exec-prefix=PATH', the package will use -PATH as the prefix for installing programs and libraries. -Documentation and other data files will still use the regular prefix. +pass the option '--exec-prefix=PREFIX' to 'configure', the package uses +PREFIX as the prefix for installing programs and libraries. +Documentation and other data files still use the regular prefix. In addition, if you use an unusual directory layout you can give -options like `--bindir=PATH' to specify different values for particular -kinds of files. Run `configure --help' for a list of the directories -you can set and what kinds of files go in them. - - If the package supports it, you can cause programs to be installed -with an extra prefix or suffix on their names by giving `configure' the -option `--program-prefix=PREFIX' or `--program-suffix=SUFFIX'. +options like '--bindir=DIR' to specify different values for particular +kinds of files. Run 'configure --help' for a list of the directories +you can set and what kinds of files go in them. In general, the +default for these options is expressed in terms of '${prefix}', so that +specifying just '--prefix' will affect all of the other directory +specifications that were not explicitly provided. + + The most portable way to affect installation locations is to pass the +correct locations to 'configure'; however, many packages provide one or +both of the following shortcuts of passing variable assignments to the +'make install' command line to change installation locations without +having to reconfigure or recompile. + + The first method involves providing an override variable for each +affected directory. For example, `make install +prefix=/alternate/directory' will choose an alternate location for all +directory configuration variables that were expressed in terms of +'${prefix}'. Any directories that were specified during 'configure', +but not in terms of '${prefix}', must each be overridden at install +time for the entire installation to be relocated. The approach of +makefile variable overrides for each directory variable is required by +the GNU Coding Standards, and ideally causes no recompilation. +However, some platforms have known limitations with the semantics of +shared libraries that end up requiring recompilation when using this +method, particularly noticeable in packages that use GNU Libtool. + + The second method involves providing the 'DESTDIR' variable. For +example, 'make install DESTDIR=/alternate/directory' will prepend +'/alternate/directory' before all installation names. The approach of +'DESTDIR' overrides is not required by the GNU Coding Standards, and +does not work on platforms that have drive letters. On the other hand, +it does better at avoiding recompilation issues, and works well even +when some directory options were not specified in terms of '${prefix}' +at 'configure' time. Optional Features ================= - Some packages pay attention to `--enable-FEATURE' options to -`configure', where FEATURE indicates an optional part of the package. -They may also pay attention to `--with-PACKAGE' options, where PACKAGE -is something like `gnu-as' or `x' (for the X Window System). The -`README' should mention any `--enable-' and `--with-' options that the + If the package supports it, you can cause programs to be installed +with an extra prefix or suffix on their names by giving 'configure' the +option '--program-prefix=PREFIX' or '--program-suffix=SUFFIX'. + + Some packages pay attention to '--enable-FEATURE' options to +'configure', where FEATURE indicates an optional part of the package. +They may also pay attention to '--with-PACKAGE' options, where PACKAGE +is something like 'gnu-as' or 'x' (for the X Window System). The +'README' should mention any '--enable-' and '--with-' options that the package recognizes. - For packages that use the X Window System, `configure' can usually + For packages that use the X Window System, 'configure' can usually find the X include and library files automatically, but if it doesn't, -you can use the `configure' options `--x-includes=DIR' and -`--x-libraries=DIR' to specify their locations. +you can use the 'configure' options '--x-includes=DIR' and +'--x-libraries=DIR' to specify their locations. + + Some packages offer the ability to configure how verbose the +execution of 'make' will be. For these packages, running `./configure +--enable-silent-rules' sets the default to minimal output, which can be +overridden with 'make V=1'; while running `./configure +--disable-silent-rules' sets the default to verbose, which can be +overridden with 'make V=0'. + +Particular systems +================== + + On HP-UX, the default C compiler is not ANSI C compatible. If GNU +CC is not installed, it is recommended to use the following options in +order to use an ANSI C compiler: + + ./configure CC="cc -Ae -D_XOPEN_SOURCE=500" + +and if that doesn't work, install pre-built binaries of GCC for HP-UX. + + HP-UX 'make' updates targets which have the same time stamps as +their prerequisites, which makes it generally unusable when shipped +generated files such as 'configure' are involved. Use GNU 'make' +instead. + + On OSF/1 a.k.a. Tru64, some versions of the default C compiler cannot +parse its '' header file. The option '-nodtk' can be used as +a workaround. If GNU CC is not installed, it is therefore recommended +to try + + ./configure CC="cc" + +and if that doesn't work, try + + ./configure CC="cc -nodtk" + + On Solaris, don't put '/usr/ucb' early in your 'PATH'. This +directory contains several dysfunctional programs; working variants of +these programs are available in '/usr/bin'. So, if you need '/usr/ucb' +in your 'PATH', put it _after_ '/usr/bin'. + + On Haiku, software installed for all users goes in '/boot/common', +not '/usr/local'. It is recommended to use the following options: + + ./configure --prefix=/boot/common Specifying the System Type ========================== - There may be some features `configure' can not figure out -automatically, but needs to determine by the type of host the package -will run on. Usually `configure' can figure that out, but if it prints -a message saying it can not guess the host type, give it the -`--host=TYPE' option. TYPE can either be a short name for the system -type, such as `sun4', or a canonical name with three fields: + There may be some features 'configure' cannot figure out +automatically, but needs to determine by the type of machine the package +will run on. Usually, assuming the package is built to be run on the +_same_ architectures, 'configure' can figure that out, but if it prints +a message saying it cannot guess the machine type, give it the +'--build=TYPE' option. TYPE can either be a short name for the system +type, such as 'sun4', or a canonical name which has the form: + CPU-COMPANY-SYSTEM -See the file `config.sub' for the possible values of each field. If -`config.sub' isn't included in this package, then this package doesn't -need to know the host type. - - If you are building compiler tools for cross-compiling, you can also -use the `--target=TYPE' option to select the type of system they will -produce code for and the `--build=TYPE' option to select the type of -system on which you are compiling the package. +where SYSTEM can have one of these forms: + + OS + KERNEL-OS + + See the file 'config.sub' for the possible values of each field. If +'config.sub' isn't included in this package, then this package doesn't +need to know the machine type. + + If you are _building_ compiler tools for cross-compiling, you should +use the option '--target=TYPE' to select the type of system they will +produce code for. + + If you want to _use_ a cross compiler, that generates code for a +platform different from the build platform, you should specify the +"host" platform (i.e., that on which the generated programs will +eventually be run) with '--host=TYPE'. Sharing Defaults ================ - If you want to set default values for `configure' scripts to share, -you can create a site shell script called `config.site' that gives -default values for variables like `CC', `cache_file', and `prefix'. -`configure' looks for `PREFIX/share/config.site' if it exists, then -`PREFIX/etc/config.site' if it exists. Or, you can set the -`CONFIG_SITE' environment variable to the location of the site script. -A warning: not all `configure' scripts look for a site script. + If you want to set default values for 'configure' scripts to share, +you can create a site shell script called 'config.site' that gives +default values for variables like 'CC', 'cache_file', and 'prefix'. +'configure' looks for 'PREFIX/share/config.site' if it exists, then +'PREFIX/etc/config.site' if it exists. Or, you can set the +'CONFIG_SITE' environment variable to the location of the site script. +A warning: not all 'configure' scripts look for a site script. -Operation Controls +Defining Variables ================== - `configure' recognizes the following options to control how it -operates. + Variables not defined in a site shell script can be set in the +environment passed to 'configure'. However, some packages may run +configure again during the build, and the customized values of these +variables may be lost. In order to avoid this problem, you should set +them in the 'configure' command line, using 'VAR=value'. For example: -`--cache-file=FILE' - Use and save the results of the tests in FILE instead of - `./config.cache'. Set FILE to `/dev/null' to disable caching, for - debugging `configure'. - -`--help' - Print a summary of the options to `configure', and exit. - -`--quiet' -`--silent' -`-q' - Do not print messages saying which checks are being made. + ./configure CC=/usr/local2/bin/gcc -`--srcdir=DIR' - Look for the package's source code in directory DIR. Usually - `configure' can determine that directory automatically. +causes the specified 'gcc' to be used as the C compiler (unless it is +overridden in the site shell script). + +Unfortunately, this technique does not work for 'CONFIG_SHELL' due to +an Autoconf limitation. Until the limitation is lifted, you can use +this workaround: + + CONFIG_SHELL=/bin/bash ./configure CONFIG_SHELL=/bin/bash -`--version' - Print the version of Autoconf used to generate the `configure' +'configure' Invocation +====================== + + 'configure' recognizes the following options to control how it +operates. + +'--help' +'-h' + Print a summary of all of the options to 'configure', and exit. + +'--help=short' +'--help=recursive' + Print a summary of the options unique to this package's + 'configure', and exit. The 'short' variant lists options used + only in the top level, while the 'recursive' variant lists options + also present in any nested packages. + +'--version' +'-V' + Print the version of Autoconf used to generate the 'configure' script, and exit. -`configure' also accepts some other, not widely useful, options. +'--cache-file=FILE' + Enable the cache: use and save the results of the tests in FILE, + traditionally 'config.cache'. FILE defaults to '/dev/null' to + disable caching. + +'--config-cache' +'-C' + Alias for '--cache-file=config.cache'. + +'--quiet' +'--silent' +'-q' + Do not print messages saying which checks are being made. To + suppress all normal output, redirect it to '/dev/null' (any error + messages will still be shown). + +'--srcdir=DIR' + Look for the package's source code in directory DIR. Usually + 'configure' can determine that directory automatically. + +'--prefix=DIR' + Use DIR as the installation prefix. *note Installation Names:: + for more details, including other options available for fine-tuning + the installation locations. + +'--no-create' +'-n' + Run the configure checks, but stop before creating any output + files. +'configure' also accepts some other, not widely useful, options. Run +'configure --help' for more details. diff -Nru units-2.16/Makefile.in units-2.19/Makefile.in --- units-2.16/Makefile.in 2017-10-03 21:30:43.000000000 +0000 +++ units-2.19/Makefile.in 2019-05-29 10:01:05.000000000 +0000 @@ -1,6 +1,8 @@ +# @configure_input@ + # Makefile for units, a program for units conversion # -# Copyright (C) 1996, 1997, 1999, 2005, 2006, 2012, 2014, 2017 +# Copyright (C) 1996, 1997, 1999, 2005, 2006, 2012, 2014, 2017, 2018 # Free Software Foundation, Inc # # This program is free software; you can redistribute it and/or modify @@ -46,17 +48,21 @@ datarootdir = @datarootdir@ datadir = @datadir@ +sharedstatedir = @sharedstatedir@ bindir = @bindir@ infodir = @infodir@ mandir = @mandir@ transform=@program_transform_name@ -DEFS=-DUNITSFILE=\"@UDAT@definitions.units\" -DLOCALEMAP=\"@UDAT@locale_map.txt\" \ +DEFS=-DUNITSFILE=\"@UDATADIR@definitions.units\" -DLOCALEMAP=\"@UDATADIR@locale_map.txt\" \ @DEFIS@ @DEFS@ CFLAGS = @CFLAGS@ +CPPFLAGS = @CPPFLAGS@ OBJECTS = units.@OBJEXT@ parse.tab.@OBJEXT@ getopt.@OBJEXT@ getopt1.@OBJEXT@ @STRFUNC@ +.PHONY: currency-units-update + .SUFFIXES: .SUFFIXES: .c .@OBJEXT@ .rc .res .texinfo .pdf @@ -86,27 +92,30 @@ UnitsMKS.texinfo UnitsMKS.pdf setvcvars.sh \ UnitsWin.texinfo UnitsWin.pdf winmkdirs.bat Makefile.Win + all: units@EXEEXT@ units.1 units.info units_cur_inst units.@OBJEXT@: units.c units.h -parse.tab.c: parse.y +parse.tab.c: parse.y bison parse.y -parse.tab.@OBJEXT@: parse.tab.c +parse.tab.@OBJEXT@: parse.tab.c units.h units@EXEEXT@: $(OBJECTS) @MKS_RES@ $(CC) $(CFLAGS) $(LDFLAGS) -o units@EXEEXT@ $(OBJECTS) @MKS_RES@ $(LIBS) units_cur_inst: units_cur - sed -e "s@outfile_name = 'currency.units'@outfile_name='@UDAT@currency.units'@"\ + sed -e "s@outfile_name = 'currency.units'@outfile_name='@CDAT@currency.units'@"\ -e "s@/usr/bin/python@$(PYTHON)@" \ - units_cur > units_cur_inst + $(srcdir)/units_cur > units_cur_inst -install-support: definitions.units currency.units units_cur_inst - $(MKDIR_P) $(DESTDIR)@UDAT@ $(DESTDIR)$(bindir) +install-support: definitions.units units_cur_inst currency-units-update + $(MKDIR_P) $(DESTDIR)@UDAT@ $(DESTDIR)$(bindir) $(DESTDIR)@CDAT@ $(INSTALL_DATA) $(srcdir)/definitions.units $(DESTDIR)@UDAT@definitions.units - $(INSTALL_DATA) $(srcdir)/currency.units $(DESTDIR)@UDAT@currency.units + -rm -f $(DESTDIR)@UDAT@currency.units + $(INSTALL_DATA) currency.units $(DESTDIR)@CDAT@currency.units + if [ @CDAT@ != @UDAT@ ];then ln -sf @CDAT@currency.units $(DESTDIR)@UDAT@currency.units;fi $(INSTALL_DATA) $(srcdir)/locale_map.txt $(DESTDIR)@UDAT@locale_map.txt if test $(HAVE_PYTHON) = yes; then \ $(INSTALL_PROGRAM) units_cur_inst $(DESTDIR)$(bindir)/`echo units_cur|sed '$(transform)'`;fi @@ -133,12 +142,12 @@ install-mks: $(INSTALL_DATA) $(srcdir)/unitsfile.ico $(DESTDIR)@UDAT@unitsfile.ico $(INSTALL_DATA) $(srcdir)/unitsprog.ico $(DESTDIR)@UDAT@unitsprog.ico - assoc .units Units.Datfile + assoc .units Units.DataFile vidir="$${ROOTDIR//\//\\}"; \ - ftype Units.Datafile "\"$$vidir"'\mksnt\viw.exe" -Uc8p8 "%1"' - registry -s -k "HKCR\\Units.Datafile" -v 'GNU units data file' + ftype Units.DataFile "\"$$vidir"'\mksnt\viw.exe" -Uc8p8 "%1"' + registry -s -k "HKCR\\Units.DataFile" -v 'GNU units data file' iconfile=$(DESTDIR)@UDAT@unitsfile.ico; \ - registry -s -k "HKCR\\Units.Datafile\\DefaultIcon" -n '' -v "$${iconfile//\//\\}" + registry -s -k "HKCR\\Units.DataFile\\DefaultIcon" -n '' -v "$${iconfile//\//\\}" units.man: units.texinfo texi2man ./texi2man units.texinfo > units.man @@ -146,23 +155,17 @@ units.1: units.man sed s!@DATAFILE@!@UDAT@definitions.units! $(srcdir)/units.man > units.1 -install-info: $(DESTDIR)$(infodir)/units.info - -$(DESTDIR)$(infodir)/units.info: units.info +install-info: units.info $(POST_INSTALL) $(MKDIR_P) $(DESTDIR)$(infodir) -# There may be a newer info file in . than in srcdir. - -if test -f units.info; then d=.; \ - else d=$(srcdir); fi; \ - $(INSTALL_DATA) $$d/units.info $@; \ + $(INSTALL_DATA) units.info $(DESTDIR)$(infodir) # Run install-info only if it exists. # Use `if' instead of just prepending `-' to the # line so we notice real errors from install-info. # We use `$(SHELL) -c' because some shells do not # fail gracefully when there is an unknown command. if test -f $(DESTDIR)$(infodir)/dir; then \ - if $(SHELL) -c 'install-info --version' \ - >/dev/null 2>&1; then \ + if $(SHELL) -c 'install-info --version' >/dev/null 2>&1; then \ install-info --dir-file=$(DESTDIR)$(infodir)/dir \ $(DESTDIR)$(infodir)/units.info; \ else true; fi \ @@ -176,6 +179,7 @@ $(DESTDIR)$(mandir)/man1/`echo units|sed '$(transform)'`.1 \ $(DESTDIR)$(infodir)/units.info \ $(DESTDIR)@UDAT@definitions.units \ + $(DESTDIR)@CDAT@currency.units \ $(DESTDIR)@UDAT@currency.units \ $(DESTDIR)@UDAT@locale_map.txt \ $(DESTDIR)@UDAT@unitsfile.ico \ @@ -203,9 +207,10 @@ -rm -f units.log UnitsMKS.log UnitsWin.log \ *.aux *.cp *.fn *.ky *.op *.pg *.toc *.tp *.vr -currency.units: units_cur +currency-units-update: @echo "Trying to update currency.units (will use existing file if this fails)" - -./units_cur + -$(srcdir)/units_cur currency.units + if [ ! -s currency.units ]; then cp $(srcdir)/currency.units currency.units;fi sig: echo units-`sed -n -e '/\#.*VERSION/s/.*"\(.*\)"/\1/gp' \ @@ -218,7 +223,7 @@ -rm -f `cat distname`.directive distname -dist: $(DISTFILES) +dist: $(DISTFILES) units @./units_cur @echo Updated currencies, running check: ./units -f definitions.units -c @@ -293,7 +298,7 @@ www: doc -rm -r wwwold wwwnew mkdir wwwnew - ./gendocs.sh -o wwwnew/units/manual units "GNU Units Manual" + ./mygendocs.sh --email adrianm@gnu.org -o wwwnew/units/manual units "GNU Units Manual" mkdir wwwold cd wwwold;CVS_RSH=ssh cvs -z3 -d:ext:adrianm@cvs.savannah.gnu.org:/webcvs/units co units cd wwwold/units/manual;ls > /tmp/wwwunits.listold @@ -310,9 +315,9 @@ @if [ -s /tmp/wwwunits.rm ]; then cd wwwold/units/manual; cvs remove `cat /tmp/wwwunits.rm`; \ cvs commit `cat /tmp/wwwunits.rm`; fi @if [ -s /tmp/wwwunits.html.add ]; then cd wwwold/units/manual/html_node; \ - cvs add `cat /tmp/wwwunits.add`; cvs commit `cat /tmp/wwwunits.add`; fi + cvs add `cat /tmp/wwwunits.add`; cvs add `cat /tmp/wwwunits.add`; fi @if [ -s /tmp/wwwunits.html.rm ]; then cd wwwold/units/manual/html_node; \ - cvs remove `cat /tmp/wwwunits.htmlrm`; cvs commit `cat /tmp/wwwunits.rm`; fi + cvs remove `cat /tmp/wwwunits.htmlrm`; cvs remove `cat /tmp/wwwunits.rm`; fi cd wwwold/units; cvs commit -rm /tmp/wwwunits.hlistnew /tmp/wwwunits.hlistold /tmp/wwwunits.listnew /tmp/wwwunits.listold -rm /tmp/wwwunits.html.rm /tmp/wwwunits.html.add /tmp/wwwunits.add /tmp/wwwunits.rm diff -Nru units-2.16/NEWS units-2.19/NEWS --- units-2.16/NEWS 2017-10-31 09:48:47.000000000 +0000 +++ units-2.19/NEWS 2019-05-29 00:14:16.000000000 +0000 @@ -1,5 +1,48 @@ GNU units NEWS - User visible changes. -Copyright (C) 1996, 1997, 1999-2007, 2010-2017 Free Software Foundation, Inc. +Copyright (C) 1996, 1997, 1999-2007, 2010-2018 Free Software Foundation, Inc. + +Version 2.19 - 28 May 2019 +* Unit definitions updated to reflect new 2019 revisions to SI and the + 2018 NIST CODATA. +* Added definitions of country and USA state areas, and physical + properties of selected woods. +* Changes only to definitions.units in this release. + +Version 2.18 - 20 October 2018 +* The yahoo currency server has disappeared. The units_cur script now + supports multiple currency sources: FloatRates the European Central + Bank, Fixer, and open exchange rates. The last two of these require + the user to obtain a personal API key for access. The base currency + can be selected using the --base option (when the source allows it, + currently only FloatRates), and the primitive unit of currency is + set to the base currency of the source. +* Added hyperbolic functions: sinh, cosh, tanh, asinh, acosh, atanh. +* Added log to arbitrary integer bases: log3, log4, log72, etc. +* Units can be redefined without a warning by adding '+' before the + unit name in definitions.units. +* Added 'quit' and 'exit' commands. +* Added support for CGS electromagnetic units with unit reductions to + combinations of sqrt(grams), sqrt(centimeters) and seconds. This + feature is activated using the -u option or UNITS_SYSTEM environment + variable, which you can set to gaussian, esu, or emu to select one + of three different CGS systems. +* Units with definitions that collide with commands ('quit', 'help', etc) + result in a warning message. +* Added !prompt command to add a prefix to the "You have:" prompt. +* Changed !message to print a blank line when it appears without text. +* Texts specified with !message appear in the log file. +* Improved compilation support for MacOS with (and without) GNU readline. +* If units is configured with --enable-relocation it can now be + installed with 'make install'. + +Version 2.17 - 25 June 2018 +* Updates to units database, including commenting out several UTF-8 + characters that fail under MacOS. +* Updated units_cur to handle bad records returned by yahoo server. +* Fixed some Makefile issues +* Moved currency.units out of /usr/share because the file is not + static and /usr/share is supposed to house static files. The new + location is $sharedstatedir which may be /var/lib or /usr/local/com. Version 2.16 - 30 October 2017 * Fixed missing USD currency code (update to units_cur and diff -Nru units-2.16/parse.tab.c units-2.19/parse.tab.c --- units-2.16/parse.tab.c 2017-09-29 20:11:22.000000000 +0000 +++ units-2.19/parse.tab.c 2019-05-29 00:32:20.000000000 +0000 @@ -1,8 +1,9 @@ -/* A Bison parser, made by GNU Bison 3.0.4. */ +/* A Bison parser, made by GNU Bison 3.3.2. */ /* Bison implementation for Yacc-like parsers in C - Copyright (C) 1984, 1989-1990, 2000-2015 Free Software Foundation, Inc. + Copyright (C) 1984, 1989-1990, 2000-2015, 2018-2019 Free Software Foundation, + Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -40,11 +41,14 @@ define necessary library symbols; they are noted "INFRINGES ON USER NAME SPACE" below. */ +/* Undocumented macros, especially those whose name start with YY_, + are private implementation details. Do not rely on them. */ + /* Identify Bison output. */ #define YYBISON 1 /* Bison version. */ -#define YYBISON_VERSION "3.0.4" +#define YYBISON_VERSION "3.3.2" /* Skeleton name. */ #define YYSKELETON_NAME "yacc.c" @@ -68,8 +72,8 @@ #define yynerrs unitsnerrs -/* Copy the first part of user declarations. */ -#line 24 "parse.y" /* yacc.c:339 */ +/* First part of user prologue. */ +#line 24 "parse.y" /* yacc.c:337 */ #include #include "units.h" @@ -149,14 +153,17 @@ return ret; } - -double -logb2(double x) -{ - return log(x)/log(2.0); +int +logunit(struct unittype *theunit, int base) +{ + if ((err=unit2num(theunit))) + return err; + theunit->factor = log(theunit->factor)/log((double)base); + if (errno) + return E_FUNC; + return 0; } - - + int funcunit(struct unittype *theunit, struct function const *fun) { @@ -194,13 +201,16 @@ -#line 198 "parse.tab.c" /* yacc.c:339 */ - +#line 205 "parse.tab.c" /* yacc.c:337 */ # ifndef YY_NULLPTR -# if defined __cplusplus && 201103L <= __cplusplus -# define YY_NULLPTR nullptr +# if defined __cplusplus +# if 201103L <= __cplusplus +# define YY_NULLPTR nullptr +# else +# define YY_NULLPTR 0 +# endif # else -# define YY_NULLPTR 0 +# define YY_NULLPTR ((void*)0) # endif # endif @@ -237,24 +247,25 @@ REAL = 258, UNIT = 259, REALFUNC = 260, - UNITFUNC = 261, - EXPONENT = 262, - MULTIPLY = 263, - MULTSTAR = 264, - DIVIDE = 265, - NUMDIV = 266, - SQRT = 267, - CUBEROOT = 268, - MULTMINUS = 269, - EOL = 270, - FUNCINV = 271, - MEMERROR = 272, - BADNUMBER = 273, - UNITEND = 274, - LASTUNSET = 275, - ADD = 276, - MINUS = 277, - UNARY = 278 + LOG = 261, + UNITFUNC = 262, + EXPONENT = 263, + MULTIPLY = 264, + MULTSTAR = 265, + DIVIDE = 266, + NUMDIV = 267, + SQRT = 268, + CUBEROOT = 269, + MULTMINUS = 270, + EOL = 271, + FUNCINV = 272, + MEMERROR = 273, + BADNUMBER = 274, + UNITEND = 275, + LASTUNSET = 276, + ADD = 277, + MINUS = 278, + UNARY = 279 }; #endif @@ -263,7 +274,7 @@ union UNITSSTYPE { -#line 154 "parse.y" /* yacc.c:355 */ +#line 157 "parse.y" /* yacc.c:352 */ double number; int integer; @@ -271,7 +282,7 @@ struct function *realfunc; struct func *unitfunc; -#line 275 "parse.tab.c" /* yacc.c:355 */ +#line 286 "parse.tab.c" /* yacc.c:352 */ }; typedef union UNITSSTYPE UNITSSTYPE; @@ -285,9 +296,7 @@ -/* Copy the second part of user declarations. */ -#line 291 "parse.tab.c" /* yacc.c:358 */ #ifdef short # undef short @@ -308,13 +317,13 @@ #ifdef YYTYPE_UINT16 typedef YYTYPE_UINT16 yytype_uint16; #else -typedef unsigned short int yytype_uint16; +typedef unsigned short yytype_uint16; #endif #ifdef YYTYPE_INT16 typedef YYTYPE_INT16 yytype_int16; #else -typedef short int yytype_int16; +typedef short yytype_int16; #endif #ifndef YYSIZE_T @@ -326,7 +335,7 @@ # include /* INFRINGES ON USER NAME SPACE */ # define YYSIZE_T size_t # else -# define YYSIZE_T unsigned int +# define YYSIZE_T unsigned # endif #endif @@ -362,15 +371,6 @@ # define YY_ATTRIBUTE_UNUSED YY_ATTRIBUTE ((__unused__)) #endif -#if !defined _Noreturn \ - && (!defined __STDC_VERSION__ || __STDC_VERSION__ < 201112) -# if defined _MSC_VER && 1200 <= _MSC_VER -# define _Noreturn __declspec (noreturn) -# else -# define _Noreturn YY_ATTRIBUTE ((__noreturn__)) -# endif -#endif - /* Suppress unused-variable warnings by "using" E. */ #if ! defined lint || defined __GNUC__ # define YYUSE(E) ((void) (E)) @@ -378,7 +378,7 @@ # define YYUSE(E) /* empty */ #endif -#if defined __GNUC__ && 407 <= __GNUC__ * 100 + __GNUC_MINOR__ +#if defined __GNUC__ && ! defined __ICC && 407 <= __GNUC__ * 100 + __GNUC_MINOR__ /* Suppress an incorrect diagnostic about yylval being uninitialized. */ # define YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN \ _Pragma ("GCC diagnostic push") \ @@ -527,36 +527,36 @@ #endif /* !YYCOPY_NEEDED */ /* YYFINAL -- State number of the termination state. */ -#define YYFINAL 34 +#define YYFINAL 36 /* YYLAST -- Last index in YYTABLE. */ -#define YYLAST 179 +#define YYLAST 176 /* YYNTOKENS -- Number of terminals. */ -#define YYNTOKENS 26 +#define YYNTOKENS 27 /* YYNNTS -- Number of nonterminals. */ #define YYNNTS 7 /* YYNRULES -- Number of rules. */ -#define YYNRULES 35 +#define YYNRULES 36 /* YYNSTATES -- Number of states. */ -#define YYNSTATES 59 +#define YYNSTATES 61 -/* YYTRANSLATE[YYX] -- Symbol number corresponding to YYX as returned - by yylex, with out-of-bounds checking. */ #define YYUNDEFTOK 2 -#define YYMAXUTOK 278 +#define YYMAXUTOK 279 +/* YYTRANSLATE(TOKEN-NUM) -- Symbol number corresponding to TOKEN-NUM + as returned by yylex, with out-of-bounds checking. */ #define YYTRANSLATE(YYX) \ - ((unsigned int) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK) + ((unsigned) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK) /* YYTRANSLATE[TOKEN-NUM] -- Symbol number corresponding to TOKEN-NUM - as returned by yylex, without out-of-bounds checking. */ + as returned by yylex. */ static const yytype_uint8 yytranslate[] = { 0, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 24, 25, 2, 2, 2, 2, 2, 2, 2, 2, + 25, 26, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, @@ -579,17 +579,17 @@ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, - 15, 16, 17, 18, 19, 20, 21, 22, 23 + 15, 16, 17, 18, 19, 20, 21, 22, 23, 24 }; #if UNITSDEBUG /* YYRLINE[YYN] -- Source line where rule number YYN was defined. */ static const yytype_uint16 yyrline[] = { - 0, 199, 199, 201, 202, 205, 206, 209, 210, 211, - 212, 214, 217, 219, 221, 225, 226, 229, 235, 236, - 237, 239, 241, 243, 244, 245, 246, 247, 248, 249, - 252, 255, 256, 257, 258, 259 + 0, 203, 203, 205, 206, 209, 210, 213, 214, 215, + 216, 218, 221, 223, 225, 229, 230, 233, 239, 240, + 241, 243, 245, 247, 248, 249, 250, 251, 252, 253, + 254, 257, 260, 261, 262, 263, 264 }; #endif @@ -598,11 +598,12 @@ First, the terminals, then, starting at YYNTOKENS, nonterminals. */ static const char *const yytname[] = { - "$end", "error", "$undefined", "REAL", "UNIT", "REALFUNC", "UNITFUNC", - "EXPONENT", "MULTIPLY", "MULTSTAR", "DIVIDE", "NUMDIV", "SQRT", - "CUBEROOT", "MULTMINUS", "EOL", "FUNCINV", "MEMERROR", "BADNUMBER", - "UNITEND", "LASTUNSET", "ADD", "MINUS", "UNARY", "'('", "')'", "$accept", - "input", "unitexpr", "expr", "numexpr", "pexpr", "list", YY_NULLPTR + "$end", "error", "$undefined", "REAL", "UNIT", "REALFUNC", "LOG", + "UNITFUNC", "EXPONENT", "MULTIPLY", "MULTSTAR", "DIVIDE", "NUMDIV", + "SQRT", "CUBEROOT", "MULTMINUS", "EOL", "FUNCINV", "MEMERROR", + "BADNUMBER", "UNITEND", "LASTUNSET", "ADD", "MINUS", "UNARY", "'('", + "')'", "$accept", "input", "unitexpr", "expr", "numexpr", "pexpr", + "list", YY_NULLPTR }; #endif @@ -613,14 +614,14 @@ { 0, 256, 257, 258, 259, 260, 261, 262, 263, 264, 265, 266, 267, 268, 269, 270, 271, 272, 273, 274, - 275, 276, 277, 278, 40, 41 + 275, 276, 277, 278, 279, 40, 41 }; # endif -#define YYPACT_NINF -18 +#define YYPACT_NINF -22 #define yypact_value_is_default(Yystate) \ - (!!((Yystate) == (-18))) + (!!((Yystate) == (-22))) #define YYTABLE_NINF -1 @@ -631,12 +632,13 @@ STATE-NUM. */ static const yytype_int16 yypact[] = { - 45, -18, -18, -18, -17, -17, 155, -17, -17, 155, - -18, 9, -18, -18, -18, -18, 155, 67, 8, -1, - 90, 16, -18, 89, -18, -18, 89, -18, -18, 89, - -18, -17, 89, 10, -18, -18, 67, 67, 67, 67, - 67, 18, 111, 155, 133, -18, -18, -18, 21, 21, - 2, 2, -18, 155, 155, 23, 133, 23, 23 + 8, -22, -22, -22, -21, -21, -21, 151, -21, -21, + 151, -22, 39, -22, -22, -22, -22, 151, 59, 16, + -8, 83, 20, -22, 82, -22, -22, -22, 82, -22, + -22, 82, -22, -21, 82, 25, -22, -22, 59, 59, + 59, 59, 59, 17, 105, 151, 128, -22, -22, -22, + 40, 40, 43, 43, -22, 151, 151, 42, 128, 42, + 42 }; /* YYDEFACT[STATE-NUM] -- Default reduction number in state STATE-NUM. @@ -645,23 +647,24 @@ static const yytype_uint8 yydefact[] = { 0, 4, 15, 19, 0, 0, 0, 0, 0, 0, - 2, 0, 32, 31, 33, 34, 0, 0, 0, 0, - 5, 18, 23, 7, 26, 27, 6, 24, 25, 8, - 35, 0, 9, 0, 1, 3, 0, 0, 0, 0, - 0, 0, 0, 0, 22, 28, 17, 13, 14, 12, - 10, 11, 16, 0, 0, 20, 21, 29, 30 + 0, 2, 0, 33, 32, 34, 35, 0, 0, 0, + 0, 5, 18, 23, 7, 26, 27, 28, 6, 24, + 25, 8, 36, 0, 9, 0, 1, 3, 0, 0, + 0, 0, 0, 0, 0, 0, 22, 29, 17, 13, + 14, 12, 10, 11, 16, 0, 0, 20, 21, 30, + 31 }; /* YYPGOTO[NTERM-NUM]. */ static const yytype_int8 yypgoto[] = { - -18, -18, -18, -14, -8, -3, 0 + -22, -22, -22, 19, 24, -3, 0 }; /* YYDEFGOTO[NTERM-NUM]. */ static const yytype_int8 yydefgoto[] = { - -1, 18, 19, 20, 21, 22, 44 + -1, 19, 20, 21, 22, 23, 46 }; /* YYTABLE[YYPACT[STATE-NUM]] -- What to do in state STATE-NUM. If @@ -669,67 +672,68 @@ number is the opposite. If YYTABLE_NINF, syntax error. */ static const yytype_uint8 yytable[] = { - 23, 24, 25, 33, 27, 28, 26, 17, 34, 29, - 36, 37, 38, 30, 35, 31, 32, 23, 36, 37, - 38, 2, 47, 48, 49, 50, 51, 41, 45, 36, - 42, 39, 40, 52, 0, 46, 23, 23, 23, 23, - 23, 0, 55, 56, 0, 0, 1, 0, 2, 3, - 4, 5, 0, 57, 58, 6, 0, 7, 8, 9, - 10, 11, 12, 13, 14, 15, 0, 16, 0, 17, - 2, 3, 4, 5, 0, 0, 0, 0, 0, 7, - 8, 9, 0, 11, 12, 13, 14, 15, 0, 16, - 0, 17, 2, 3, 4, 5, 42, 0, 36, 37, - 38, 7, 8, 43, 0, 11, 12, 13, 14, 15, - 0, 39, 40, 17, 2, 3, 4, 5, 0, 0, - 0, 0, 0, 7, 8, 53, 0, 11, 12, 13, - 14, 15, 0, 54, 0, 17, 2, 3, 4, 5, - 42, 0, 0, 0, 0, 7, 8, 0, 0, 11, - 12, 13, 14, 15, 0, 0, 0, 17, 2, 3, - 4, 5, 0, 0, 0, 0, 0, 7, 8, 0, - 0, 11, 12, 13, 14, 15, 0, 0, 0, 17 + 24, 25, 26, 27, 18, 29, 30, 28, 37, 1, + 31, 2, 3, 4, 5, 6, 36, 34, 24, 7, + 2, 8, 9, 10, 11, 12, 13, 14, 15, 16, + 47, 17, 43, 18, 38, 39, 40, 35, 24, 24, + 24, 24, 24, 32, 57, 58, 33, 41, 42, 38, + 44, 48, 38, 39, 40, 59, 60, 49, 50, 51, + 52, 53, 2, 3, 4, 5, 6, 54, 0, 0, + 0, 0, 8, 9, 10, 0, 12, 13, 14, 15, + 16, 0, 17, 0, 18, 2, 3, 4, 5, 6, + 44, 0, 38, 39, 40, 8, 9, 45, 0, 12, + 13, 14, 15, 16, 0, 41, 42, 18, 2, 3, + 4, 5, 6, 0, 0, 0, 0, 0, 8, 9, + 55, 0, 12, 13, 14, 15, 16, 0, 56, 0, + 18, 2, 3, 4, 5, 6, 44, 0, 0, 0, + 0, 8, 9, 0, 0, 12, 13, 14, 15, 16, + 0, 0, 0, 18, 2, 3, 4, 5, 6, 0, + 0, 0, 0, 0, 8, 9, 0, 0, 12, 13, + 14, 15, 16, 0, 0, 0, 18 }; static const yytype_int8 yycheck[] = { - 0, 4, 5, 17, 7, 8, 6, 24, 0, 9, - 8, 9, 10, 4, 15, 6, 16, 17, 8, 9, - 10, 3, 36, 37, 38, 39, 40, 11, 31, 8, - 7, 21, 22, 41, -1, 25, 36, 37, 38, 39, - 40, -1, 42, 43, -1, -1, 1, -1, 3, 4, - 5, 6, -1, 53, 54, 10, -1, 12, 13, 14, - 15, 16, 17, 18, 19, 20, -1, 22, -1, 24, - 3, 4, 5, 6, -1, -1, -1, -1, -1, 12, - 13, 14, -1, 16, 17, 18, 19, 20, -1, 22, - -1, 24, 3, 4, 5, 6, 7, -1, 8, 9, - 10, 12, 13, 14, -1, 16, 17, 18, 19, 20, - -1, 21, 22, 24, 3, 4, 5, 6, -1, -1, - -1, -1, -1, 12, 13, 14, -1, 16, 17, 18, - 19, 20, -1, 22, -1, 24, 3, 4, 5, 6, - 7, -1, -1, -1, -1, 12, 13, -1, -1, 16, - 17, 18, 19, 20, -1, -1, -1, 24, 3, 4, - 5, 6, -1, -1, -1, -1, -1, 12, 13, -1, - -1, 16, 17, 18, 19, 20, -1, -1, -1, 24 + 0, 4, 5, 6, 25, 8, 9, 7, 16, 1, + 10, 3, 4, 5, 6, 7, 0, 17, 18, 11, + 3, 13, 14, 15, 16, 17, 18, 19, 20, 21, + 33, 23, 12, 25, 9, 10, 11, 18, 38, 39, + 40, 41, 42, 4, 44, 45, 7, 22, 23, 9, + 8, 26, 9, 10, 11, 55, 56, 38, 39, 40, + 41, 42, 3, 4, 5, 6, 7, 43, -1, -1, + -1, -1, 13, 14, 15, -1, 17, 18, 19, 20, + 21, -1, 23, -1, 25, 3, 4, 5, 6, 7, + 8, -1, 9, 10, 11, 13, 14, 15, -1, 17, + 18, 19, 20, 21, -1, 22, 23, 25, 3, 4, + 5, 6, 7, -1, -1, -1, -1, -1, 13, 14, + 15, -1, 17, 18, 19, 20, 21, -1, 23, -1, + 25, 3, 4, 5, 6, 7, 8, -1, -1, -1, + -1, 13, 14, -1, -1, 17, 18, 19, 20, 21, + -1, -1, -1, 25, 3, 4, 5, 6, 7, -1, + -1, -1, -1, -1, 13, 14, -1, -1, 17, 18, + 19, 20, 21, -1, -1, -1, 25 }; /* YYSTOS[STATE-NUM] -- The (internal number of the) accessing symbol of state STATE-NUM. */ static const yytype_uint8 yystos[] = { - 0, 1, 3, 4, 5, 6, 10, 12, 13, 14, - 15, 16, 17, 18, 19, 20, 22, 24, 27, 28, - 29, 30, 31, 32, 31, 31, 32, 31, 31, 32, - 4, 6, 32, 29, 0, 15, 8, 9, 10, 21, - 22, 11, 7, 14, 32, 31, 25, 29, 29, 29, - 29, 29, 30, 14, 22, 32, 32, 32, 32 + 0, 1, 3, 4, 5, 6, 7, 11, 13, 14, + 15, 16, 17, 18, 19, 20, 21, 23, 25, 28, + 29, 30, 31, 32, 33, 32, 32, 32, 33, 32, + 32, 33, 4, 7, 33, 30, 0, 16, 9, 10, + 11, 22, 23, 12, 8, 15, 33, 32, 26, 30, + 30, 30, 30, 30, 31, 15, 23, 33, 33, 33, + 33 }; /* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */ static const yytype_uint8 yyr1[] = { - 0, 26, 27, 27, 27, 28, 28, 29, 29, 29, - 29, 29, 29, 29, 29, 30, 30, 31, 32, 32, - 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, - 32, 32, 32, 32, 32, 32 + 0, 27, 28, 28, 28, 29, 29, 30, 30, 30, + 30, 30, 30, 30, 30, 31, 31, 32, 33, 33, + 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, + 33, 33, 33, 33, 33, 33, 33 }; /* YYR2[YYN] -- Number of symbols on the right hand side of rule YYN. */ @@ -737,8 +741,8 @@ { 0, 2, 1, 2, 1, 1, 2, 1, 2, 2, 3, 3, 3, 3, 3, 1, 3, 3, 1, 1, - 3, 3, 2, 1, 2, 2, 2, 2, 3, 4, - 4, 1, 1, 1, 1, 2 + 3, 3, 2, 1, 2, 2, 2, 2, 2, 3, + 4, 4, 1, 1, 1, 1, 2 }; @@ -754,22 +758,22 @@ #define YYRECOVERING() (!!yyerrstatus) -#define YYBACKUP(Token, Value) \ -do \ - if (yychar == YYEMPTY) \ - { \ - yychar = (Token); \ - yylval = (Value); \ - YYPOPSTACK (yylen); \ - yystate = *yyssp; \ - goto yybackup; \ - } \ - else \ - { \ - yyerror (comm, YY_("syntax error: cannot back up")); \ - YYERROR; \ - } \ -while (0) +#define YYBACKUP(Token, Value) \ + do \ + if (yychar == YYEMPTY) \ + { \ + yychar = (Token); \ + yylval = (Value); \ + YYPOPSTACK (yylen); \ + yystate = *yyssp; \ + goto yybackup; \ + } \ + else \ + { \ + yyerror (comm, YY_("syntax error: cannot back up")); \ + YYERROR; \ + } \ + while (0) /* Error token number */ #define YYTERROR 1 @@ -809,38 +813,38 @@ } while (0) -/*----------------------------------------. -| Print this symbol's value on YYOUTPUT. | -`----------------------------------------*/ +/*-----------------------------------. +| Print this symbol's value on YYO. | +`-----------------------------------*/ static void -yy_symbol_value_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep, struct commtype *comm) +yy_symbol_value_print (FILE *yyo, int yytype, YYSTYPE const * const yyvaluep, struct commtype *comm) { - FILE *yyo = yyoutput; - YYUSE (yyo); + FILE *yyoutput = yyo; + YYUSE (yyoutput); YYUSE (comm); if (!yyvaluep) return; # ifdef YYPRINT if (yytype < YYNTOKENS) - YYPRINT (yyoutput, yytoknum[yytype], *yyvaluep); + YYPRINT (yyo, yytoknum[yytype], *yyvaluep); # endif YYUSE (yytype); } -/*--------------------------------. -| Print this symbol on YYOUTPUT. | -`--------------------------------*/ +/*---------------------------. +| Print this symbol on YYO. | +`---------------------------*/ static void -yy_symbol_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep, struct commtype *comm) +yy_symbol_print (FILE *yyo, int yytype, YYSTYPE const * const yyvaluep, struct commtype *comm) { - YYFPRINTF (yyoutput, "%s %s (", + YYFPRINTF (yyo, "%s %s (", yytype < YYNTOKENS ? "token" : "nterm", yytname[yytype]); - yy_symbol_value_print (yyoutput, yytype, yyvaluep, comm); - YYFPRINTF (yyoutput, ")"); + yy_symbol_value_print (yyo, yytype, yyvaluep, comm); + YYFPRINTF (yyo, ")"); } /*------------------------------------------------------------------. @@ -874,7 +878,7 @@ static void yy_reduce_print (yytype_int16 *yyssp, YYSTYPE *yyvsp, int yyrule, struct commtype *comm) { - unsigned long int yylno = yyrline[yyrule]; + unsigned long yylno = yyrline[yyrule]; int yynrhs = yyr2[yyrule]; int yyi; YYFPRINTF (stderr, "Reducing stack by rule %d (line %lu):\n", @@ -885,7 +889,7 @@ YYFPRINTF (stderr, " $%d = ", yyi + 1); yy_symbol_print (stderr, yystos[yyssp[yyi + 1 - yynrhs]], - &(yyvsp[(yyi + 1) - (yynrhs)]) + &yyvsp[(yyi + 1) - (yynrhs)] , comm); YYFPRINTF (stderr, "\n"); } @@ -989,7 +993,10 @@ case '\\': if (*++yyp != '\\') goto do_not_strip_quotes; - /* Fall through. */ + else + goto append; + + append: default: if (yyres) yyres[yyn] = *yyp; @@ -1007,7 +1014,7 @@ if (! yyres) return yystrlen (yystr); - return yystpcpy (yyres, yystr) - yyres; + return (YYSIZE_T) (yystpcpy (yyres, yystr) - yyres); } # endif @@ -1085,10 +1092,10 @@ yyarg[yycount++] = yytname[yyx]; { YYSIZE_T yysize1 = yysize + yytnamerr (YY_NULLPTR, yytname[yyx]); - if (! (yysize <= yysize1 - && yysize1 <= YYSTACK_ALLOC_MAXIMUM)) + if (yysize <= yysize1 && yysize1 <= YYSTACK_ALLOC_MAXIMUM) + yysize = yysize1; + else return 2; - yysize = yysize1; } } } @@ -1100,6 +1107,7 @@ case N: \ yyformat = S; \ break + default: /* Avoid compiler warnings. */ YYCASE_(0, YY_("syntax error")); YYCASE_(1, YY_("syntax error, unexpected %s")); YYCASE_(2, YY_("syntax error, unexpected %s, expecting %s")); @@ -1111,9 +1119,10 @@ { YYSIZE_T yysize1 = yysize + yystrlen (yyformat); - if (! (yysize <= yysize1 && yysize1 <= YYSTACK_ALLOC_MAXIMUM)) + if (yysize <= yysize1 && yysize1 <= YYSTACK_ALLOC_MAXIMUM) + yysize = yysize1; + else return 2; - yysize = yysize1; } if (*yymsg_alloc < yysize) @@ -1163,37 +1172,36 @@ YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN switch (yytype) { - case 4: /* UNIT */ -#line 187 "parse.y" /* yacc.c:1257 */ + case 4: /* UNIT */ +#line 191 "parse.y" /* yacc.c:1257 */ { destroyunit(((*yyvaluep).unit));} -#line 1170 "parse.tab.c" /* yacc.c:1257 */ +#line 1179 "parse.tab.c" /* yacc.c:1257 */ break; - case 28: /* unitexpr */ -#line 187 "parse.y" /* yacc.c:1257 */ + case 29: /* unitexpr */ +#line 191 "parse.y" /* yacc.c:1257 */ { destroyunit(((*yyvaluep).unit));} -#line 1176 "parse.tab.c" /* yacc.c:1257 */ +#line 1185 "parse.tab.c" /* yacc.c:1257 */ break; - case 29: /* expr */ -#line 187 "parse.y" /* yacc.c:1257 */ + case 30: /* expr */ +#line 191 "parse.y" /* yacc.c:1257 */ { destroyunit(((*yyvaluep).unit));} -#line 1182 "parse.tab.c" /* yacc.c:1257 */ +#line 1191 "parse.tab.c" /* yacc.c:1257 */ break; - case 31: /* pexpr */ -#line 187 "parse.y" /* yacc.c:1257 */ + case 32: /* pexpr */ +#line 191 "parse.y" /* yacc.c:1257 */ { destroyunit(((*yyvaluep).unit));} -#line 1188 "parse.tab.c" /* yacc.c:1257 */ +#line 1197 "parse.tab.c" /* yacc.c:1257 */ break; - case 32: /* list */ -#line 187 "parse.y" /* yacc.c:1257 */ + case 33: /* list */ +#line 191 "parse.y" /* yacc.c:1257 */ { destroyunit(((*yyvaluep).unit));} -#line 1194 "parse.tab.c" /* yacc.c:1257 */ +#line 1203 "parse.tab.c" /* yacc.c:1257 */ break; - default: break; } @@ -1279,23 +1287,31 @@ yychar = YYEMPTY; /* Cause a token to be read. */ goto yysetstate; + /*------------------------------------------------------------. -| yynewstate -- Push a new state, which is found in yystate. | +| yynewstate -- push a new state, which is found in yystate. | `------------------------------------------------------------*/ - yynewstate: +yynewstate: /* In all cases, when you get here, the value and location stacks have just been pushed. So pushing a state here evens the stacks. */ yyssp++; - yysetstate: - *yyssp = yystate; + +/*--------------------------------------------------------------------. +| yynewstate -- set current state (the top of the stack) to yystate. | +`--------------------------------------------------------------------*/ +yysetstate: + *yyssp = (yytype_int16) yystate; if (yyss + yystacksize - 1 <= yyssp) +#if !defined yyoverflow && !defined YYSTACK_RELOCATE + goto yyexhaustedlab; +#else { /* Get the current used size of the three stacks, in elements. */ - YYSIZE_T yysize = yyssp - yyss + 1; + YYSIZE_T yysize = (YYSIZE_T) (yyssp - yyss + 1); -#ifdef yyoverflow +# if defined yyoverflow { /* Give user a chance to reallocate the stack. Use copies of these so that the &'s don't force the real ones into @@ -1311,14 +1327,10 @@ &yyss1, yysize * sizeof (*yyssp), &yyvs1, yysize * sizeof (*yyvsp), &yystacksize); - yyss = yyss1; yyvs = yyvs1; } -#else /* no yyoverflow */ -# ifndef YYSTACK_RELOCATE - goto yyexhaustedlab; -# else +# else /* defined YYSTACK_RELOCATE */ /* Extend the stack our own way. */ if (YYMAXDEPTH <= yystacksize) goto yyexhaustedlab; @@ -1334,22 +1346,22 @@ goto yyexhaustedlab; YYSTACK_RELOCATE (yyss_alloc, yyss); YYSTACK_RELOCATE (yyvs_alloc, yyvs); -# undef YYSTACK_RELOCATE +# undef YYSTACK_RELOCATE if (yyss1 != yyssa) YYSTACK_FREE (yyss1); } # endif -#endif /* no yyoverflow */ yyssp = yyss + yysize - 1; yyvsp = yyvs + yysize - 1; YYDPRINTF ((stderr, "Stack size increased to %lu\n", - (unsigned long int) yystacksize)); + (unsigned long) yystacksize)); if (yyss + yystacksize - 1 <= yyssp) YYABORT; } +#endif /* !defined yyoverflow && !defined YYSTACK_RELOCATE */ YYDPRINTF ((stderr, "Entering state %d\n", yystate)); @@ -1358,11 +1370,11 @@ goto yybackup; + /*-----------. | yybackup. | `-----------*/ yybackup: - /* Do appropriate processing given the current state. Read a lookahead token if we need one and don't already have one. */ @@ -1435,7 +1447,7 @@ /*-----------------------------. -| yyreduce -- Do a reduction. | +| yyreduce -- do a reduction. | `-----------------------------*/ yyreduce: /* yyn is the number of a rule to reduce with. */ @@ -1456,223 +1468,229 @@ switch (yyn) { case 2: -#line 199 "parse.y" /* yacc.c:1646 */ +#line 203 "parse.y" /* yacc.c:1652 */ { comm->result = makenumunit(1,&err); CHECK(0); comm->errorcode = 0; YYACCEPT; } -#line 1463 "parse.tab.c" /* yacc.c:1646 */ +#line 1475 "parse.tab.c" /* yacc.c:1652 */ break; case 3: -#line 201 "parse.y" /* yacc.c:1646 */ +#line 205 "parse.y" /* yacc.c:1652 */ { comm->result = (yyvsp[-1].unit); comm->errorcode = 0; YYACCEPT; } -#line 1469 "parse.tab.c" /* yacc.c:1646 */ +#line 1481 "parse.tab.c" /* yacc.c:1652 */ break; case 4: -#line 202 "parse.y" /* yacc.c:1646 */ +#line 206 "parse.y" /* yacc.c:1652 */ { YYABORT; } -#line 1475 "parse.tab.c" /* yacc.c:1646 */ +#line 1487 "parse.tab.c" /* yacc.c:1652 */ break; case 5: -#line 205 "parse.y" /* yacc.c:1646 */ +#line 209 "parse.y" /* yacc.c:1652 */ { (yyval.unit) = (yyvsp[0].unit);} -#line 1481 "parse.tab.c" /* yacc.c:1646 */ +#line 1493 "parse.tab.c" /* yacc.c:1652 */ break; case 6: -#line 206 "parse.y" /* yacc.c:1646 */ +#line 210 "parse.y" /* yacc.c:1652 */ { invertunit((yyvsp[0].unit)); (yyval.unit)=(yyvsp[0].unit);} -#line 1487 "parse.tab.c" /* yacc.c:1646 */ +#line 1499 "parse.tab.c" /* yacc.c:1652 */ break; case 7: -#line 209 "parse.y" /* yacc.c:1646 */ +#line 213 "parse.y" /* yacc.c:1652 */ { (yyval.unit) = (yyvsp[0].unit); } -#line 1493 "parse.tab.c" /* yacc.c:1646 */ +#line 1505 "parse.tab.c" /* yacc.c:1652 */ break; case 8: -#line 210 "parse.y" /* yacc.c:1646 */ +#line 214 "parse.y" /* yacc.c:1652 */ { (yyval.unit) = (yyvsp[0].unit); (yyval.unit)->factor *= -1; } -#line 1499 "parse.tab.c" /* yacc.c:1646 */ +#line 1511 "parse.tab.c" /* yacc.c:1652 */ break; case 9: -#line 211 "parse.y" /* yacc.c:1646 */ +#line 215 "parse.y" /* yacc.c:1652 */ { (yyval.unit) = (yyvsp[0].unit); (yyval.unit)->factor *= -1; } -#line 1505 "parse.tab.c" /* yacc.c:1646 */ +#line 1517 "parse.tab.c" /* yacc.c:1652 */ break; case 10: -#line 212 "parse.y" /* yacc.c:1646 */ +#line 216 "parse.y" /* yacc.c:1652 */ { err = addunit((yyvsp[-2].unit),(yyvsp[0].unit)); destroyunit((yyvsp[0].unit)); CHECK((yyvsp[-2].unit));(yyval.unit)=(yyvsp[-2].unit);} -#line 1512 "parse.tab.c" /* yacc.c:1646 */ +#line 1524 "parse.tab.c" /* yacc.c:1652 */ break; case 11: -#line 214 "parse.y" /* yacc.c:1646 */ +#line 218 "parse.y" /* yacc.c:1652 */ { (yyvsp[0].unit)->factor *= -1; err = addunit((yyvsp[-2].unit),(yyvsp[0].unit)); destroyunit((yyvsp[0].unit)); CHECK((yyvsp[-2].unit));(yyval.unit)=(yyvsp[-2].unit);} -#line 1520 "parse.tab.c" /* yacc.c:1646 */ +#line 1532 "parse.tab.c" /* yacc.c:1652 */ break; case 12: -#line 217 "parse.y" /* yacc.c:1646 */ +#line 221 "parse.y" /* yacc.c:1652 */ { err = divunit((yyvsp[-2].unit), (yyvsp[0].unit)); destroyunit((yyvsp[0].unit)); CHECK((yyvsp[-2].unit));(yyval.unit)=(yyvsp[-2].unit);} -#line 1527 "parse.tab.c" /* yacc.c:1646 */ +#line 1539 "parse.tab.c" /* yacc.c:1652 */ break; case 13: -#line 219 "parse.y" /* yacc.c:1646 */ +#line 223 "parse.y" /* yacc.c:1652 */ { err = multunit((yyvsp[-2].unit),(yyvsp[0].unit)); destroyunit((yyvsp[0].unit)); CHECK((yyvsp[-2].unit));(yyval.unit)=(yyvsp[-2].unit);} -#line 1534 "parse.tab.c" /* yacc.c:1646 */ +#line 1546 "parse.tab.c" /* yacc.c:1652 */ break; case 14: -#line 221 "parse.y" /* yacc.c:1646 */ +#line 225 "parse.y" /* yacc.c:1652 */ { err = multunit((yyvsp[-2].unit),(yyvsp[0].unit)); destroyunit((yyvsp[0].unit)); CHECK((yyvsp[-2].unit));(yyval.unit)=(yyvsp[-2].unit);} -#line 1541 "parse.tab.c" /* yacc.c:1646 */ +#line 1553 "parse.tab.c" /* yacc.c:1652 */ break; case 15: -#line 225 "parse.y" /* yacc.c:1646 */ +#line 229 "parse.y" /* yacc.c:1652 */ { (yyval.number) = (yyvsp[0].number); } -#line 1547 "parse.tab.c" /* yacc.c:1646 */ +#line 1559 "parse.tab.c" /* yacc.c:1652 */ break; case 16: -#line 226 "parse.y" /* yacc.c:1646 */ +#line 230 "parse.y" /* yacc.c:1652 */ { (yyval.number) = (yyvsp[-2].number) / (yyvsp[0].number); } -#line 1553 "parse.tab.c" /* yacc.c:1646 */ +#line 1565 "parse.tab.c" /* yacc.c:1652 */ break; case 17: -#line 229 "parse.y" /* yacc.c:1646 */ +#line 233 "parse.y" /* yacc.c:1652 */ { (yyval.unit) = (yyvsp[-1].unit); } -#line 1559 "parse.tab.c" /* yacc.c:1646 */ +#line 1571 "parse.tab.c" /* yacc.c:1652 */ break; case 18: -#line 235 "parse.y" /* yacc.c:1646 */ +#line 239 "parse.y" /* yacc.c:1652 */ { (yyval.unit) = makenumunit((yyvsp[0].number),&err); CHECK(0);} -#line 1565 "parse.tab.c" /* yacc.c:1646 */ +#line 1577 "parse.tab.c" /* yacc.c:1652 */ break; case 19: -#line 236 "parse.y" /* yacc.c:1646 */ +#line 240 "parse.y" /* yacc.c:1652 */ { (yyval.unit) = (yyvsp[0].unit); } -#line 1571 "parse.tab.c" /* yacc.c:1646 */ +#line 1583 "parse.tab.c" /* yacc.c:1652 */ break; case 20: -#line 237 "parse.y" /* yacc.c:1646 */ +#line 241 "parse.y" /* yacc.c:1652 */ { err = unitpower((yyvsp[-2].unit),(yyvsp[0].unit));destroyunit((yyvsp[0].unit)); CHECK((yyvsp[-2].unit));(yyval.unit)=(yyvsp[-2].unit);} -#line 1578 "parse.tab.c" /* yacc.c:1646 */ +#line 1590 "parse.tab.c" /* yacc.c:1652 */ break; case 21: -#line 239 "parse.y" /* yacc.c:1646 */ +#line 243 "parse.y" /* yacc.c:1652 */ { err = multunit((yyvsp[-2].unit),(yyvsp[0].unit)); destroyunit((yyvsp[0].unit)); CHECK((yyvsp[-2].unit));(yyval.unit)=(yyvsp[-2].unit);} -#line 1585 "parse.tab.c" /* yacc.c:1646 */ +#line 1597 "parse.tab.c" /* yacc.c:1652 */ break; case 22: -#line 241 "parse.y" /* yacc.c:1646 */ +#line 245 "parse.y" /* yacc.c:1652 */ { err = multunit((yyvsp[-1].unit),(yyvsp[0].unit)); destroyunit((yyvsp[0].unit)); CHECK((yyvsp[-1].unit));(yyval.unit)=(yyvsp[-1].unit);} -#line 1592 "parse.tab.c" /* yacc.c:1646 */ +#line 1604 "parse.tab.c" /* yacc.c:1652 */ break; case 23: -#line 243 "parse.y" /* yacc.c:1646 */ +#line 247 "parse.y" /* yacc.c:1652 */ { (yyval.unit)=(yyvsp[0].unit); } -#line 1598 "parse.tab.c" /* yacc.c:1646 */ +#line 1610 "parse.tab.c" /* yacc.c:1652 */ break; case 24: -#line 244 "parse.y" /* yacc.c:1646 */ +#line 248 "parse.y" /* yacc.c:1652 */ { err = rootunit((yyvsp[0].unit),2); CHECK((yyvsp[0].unit)); (yyval.unit)=(yyvsp[0].unit);} -#line 1604 "parse.tab.c" /* yacc.c:1646 */ +#line 1616 "parse.tab.c" /* yacc.c:1652 */ break; case 25: -#line 245 "parse.y" /* yacc.c:1646 */ +#line 249 "parse.y" /* yacc.c:1652 */ { err = rootunit((yyvsp[0].unit),3); CHECK((yyvsp[0].unit)); (yyval.unit)=(yyvsp[0].unit);} -#line 1610 "parse.tab.c" /* yacc.c:1646 */ +#line 1622 "parse.tab.c" /* yacc.c:1652 */ break; case 26: -#line 246 "parse.y" /* yacc.c:1646 */ +#line 250 "parse.y" /* yacc.c:1652 */ { err = funcunit((yyvsp[0].unit),(yyvsp[-1].realfunc));CHECK((yyvsp[0].unit)); (yyval.unit)=(yyvsp[0].unit);} -#line 1616 "parse.tab.c" /* yacc.c:1646 */ +#line 1628 "parse.tab.c" /* yacc.c:1652 */ break; case 27: -#line 247 "parse.y" /* yacc.c:1646 */ - { err = evalfunc((yyvsp[0].unit),(yyvsp[-1].unitfunc),0,0); CHECK((yyvsp[0].unit));(yyval.unit)=(yyvsp[0].unit);} -#line 1622 "parse.tab.c" /* yacc.c:1646 */ +#line 251 "parse.y" /* yacc.c:1652 */ + { err = logunit((yyvsp[0].unit),(yyvsp[-1].integer)); CHECK((yyvsp[0].unit)); (yyval.unit)=(yyvsp[0].unit);} +#line 1634 "parse.tab.c" /* yacc.c:1652 */ break; case 28: -#line 248 "parse.y" /* yacc.c:1646 */ - { err = evalfunc((yyvsp[0].unit),(yyvsp[-1].unitfunc),1,0); CHECK((yyvsp[0].unit));(yyval.unit)=(yyvsp[0].unit);} -#line 1628 "parse.tab.c" /* yacc.c:1646 */ +#line 252 "parse.y" /* yacc.c:1652 */ + { err = evalfunc((yyvsp[0].unit),(yyvsp[-1].unitfunc),0,0); CHECK((yyvsp[0].unit));(yyval.unit)=(yyvsp[0].unit);} +#line 1640 "parse.tab.c" /* yacc.c:1652 */ break; case 29: -#line 250 "parse.y" /* yacc.c:1646 */ - { (yyvsp[0].unit)->factor *= -1; err = unitpower((yyvsp[-3].unit),(yyvsp[0].unit)); - destroyunit((yyvsp[0].unit));CHECK((yyvsp[-3].unit));(yyval.unit)=(yyvsp[-3].unit);} -#line 1635 "parse.tab.c" /* yacc.c:1646 */ +#line 253 "parse.y" /* yacc.c:1652 */ + { err = evalfunc((yyvsp[0].unit),(yyvsp[-1].unitfunc),1,0); CHECK((yyvsp[0].unit));(yyval.unit)=(yyvsp[0].unit);} +#line 1646 "parse.tab.c" /* yacc.c:1652 */ break; case 30: -#line 253 "parse.y" /* yacc.c:1646 */ +#line 255 "parse.y" /* yacc.c:1652 */ { (yyvsp[0].unit)->factor *= -1; err = unitpower((yyvsp[-3].unit),(yyvsp[0].unit)); destroyunit((yyvsp[0].unit));CHECK((yyvsp[-3].unit));(yyval.unit)=(yyvsp[-3].unit);} -#line 1642 "parse.tab.c" /* yacc.c:1646 */ +#line 1653 "parse.tab.c" /* yacc.c:1652 */ break; case 31: -#line 255 "parse.y" /* yacc.c:1646 */ - { err = E_BADNUM; CHECK(0); } -#line 1648 "parse.tab.c" /* yacc.c:1646 */ +#line 258 "parse.y" /* yacc.c:1652 */ + { (yyvsp[0].unit)->factor *= -1; err = unitpower((yyvsp[-3].unit),(yyvsp[0].unit)); + destroyunit((yyvsp[0].unit));CHECK((yyvsp[-3].unit));(yyval.unit)=(yyvsp[-3].unit);} +#line 1660 "parse.tab.c" /* yacc.c:1652 */ break; case 32: -#line 256 "parse.y" /* yacc.c:1646 */ - { err = E_PARSEMEM; CHECK(0); } -#line 1654 "parse.tab.c" /* yacc.c:1646 */ +#line 260 "parse.y" /* yacc.c:1652 */ + { err = E_BADNUM; CHECK(0); } +#line 1666 "parse.tab.c" /* yacc.c:1652 */ break; case 33: -#line 257 "parse.y" /* yacc.c:1646 */ - { err = E_UNITEND; CHECK(0); } -#line 1660 "parse.tab.c" /* yacc.c:1646 */ +#line 261 "parse.y" /* yacc.c:1652 */ + { err = E_PARSEMEM; CHECK(0); } +#line 1672 "parse.tab.c" /* yacc.c:1652 */ break; case 34: -#line 258 "parse.y" /* yacc.c:1646 */ - { err = E_LASTUNSET;CHECK(0); } -#line 1666 "parse.tab.c" /* yacc.c:1646 */ +#line 262 "parse.y" /* yacc.c:1652 */ + { err = E_UNITEND; CHECK(0); } +#line 1678 "parse.tab.c" /* yacc.c:1652 */ break; case 35: -#line 259 "parse.y" /* yacc.c:1646 */ +#line 263 "parse.y" /* yacc.c:1652 */ + { err = E_LASTUNSET;CHECK(0); } +#line 1684 "parse.tab.c" /* yacc.c:1652 */ + break; + + case 36: +#line 264 "parse.y" /* yacc.c:1652 */ { err = E_NOTAFUNC; CHECK((yyvsp[0].unit));} -#line 1672 "parse.tab.c" /* yacc.c:1646 */ +#line 1690 "parse.tab.c" /* yacc.c:1652 */ break; -#line 1676 "parse.tab.c" /* yacc.c:1646 */ +#line 1694 "parse.tab.c" /* yacc.c:1652 */ default: break; } /* User semantic actions sometimes alter yychar, and that requires @@ -1697,14 +1715,13 @@ /* Now 'shift' the result of the reduction. Determine what state that goes to, based on the state we popped back to and the rule number reduced by. */ - - yyn = yyr1[yyn]; - - yystate = yypgoto[yyn - YYNTOKENS] + *yyssp; - if (0 <= yystate && yystate <= YYLAST && yycheck[yystate] == *yyssp) - yystate = yytable[yystate]; - else - yystate = yydefgoto[yyn - YYNTOKENS]; + { + const int yylhs = yyr1[yyn] - YYNTOKENS; + const int yyi = yypgoto[yylhs] + *yyssp; + yystate = (0 <= yyi && yyi <= YYLAST && yycheck[yyi] == *yyssp + ? yytable[yyi] + : yydefgoto[yylhs]); + } goto yynewstate; @@ -1787,12 +1804,10 @@ | yyerrorlab -- error raised explicitly by YYERROR. | `---------------------------------------------------*/ yyerrorlab: - - /* Pacify compilers like GCC when the user code never invokes - YYERROR and the label yyerrorlab therefore never appears in user - code. */ - if (/*CONSTCOND*/ 0) - goto yyerrorlab; + /* Pacify compilers when the user code never invokes YYERROR and the + label yyerrorlab therefore never appears in user code. */ + if (0) + YYERROR; /* Do not reclaim the symbols of the rule whose action triggered this YYERROR. */ @@ -1854,6 +1869,7 @@ yyresult = 0; goto yyreturn; + /*-----------------------------------. | yyabortlab -- YYABORT comes here. | `-----------------------------------*/ @@ -1861,6 +1877,7 @@ yyresult = 1; goto yyreturn; + #if !defined yyoverflow || YYERROR_VERBOSE /*-------------------------------------------------. | yyexhaustedlab -- memory exhaustion comes here. | @@ -1871,6 +1888,10 @@ /* Fall through. */ #endif + +/*-----------------------------------------------------. +| yyreturn -- parsing is finished, return the result. | +`-----------------------------------------------------*/ yyreturn: if (yychar != YYEMPTY) { @@ -1900,7 +1921,7 @@ #endif return yyresult; } -#line 262 "parse.y" /* yacc.c:1906 */ +#line 267 "parse.y" /* yacc.c:1918 */ struct function @@ -1909,11 +1930,16 @@ {"tan", tan, ANGLEIN}, {"ln", log, DIMENSIONLESS}, {"log", log10, DIMENSIONLESS}, - {"log2", logb2, DIMENSIONLESS}, {"exp", exp, DIMENSIONLESS}, {"acos", acos, ANGLEOUT}, {"atan", atan, ANGLEOUT}, {"asin", asin, ANGLEOUT}, + {"sinh", sinh, DIMENSIONLESS}, + {"cosh", cosh, DIMENSIONLESS}, + {"tanh", tanh, DIMENSIONLESS}, + {"asinh", asinh, DIMENSIONLESS}, + {"acosh", acosh, DIMENSIONLESS}, + {"atanh", atanh, DIMENSIONLESS}, {0, 0, 0}}; struct { @@ -1947,7 +1973,7 @@ const char *inptr; char *name; - char *nonunitchars = "~;+-*/|\t\n^ ()"; /* Chars not allowed in unit name */ + char *nonunitchars = "~;+-*/|\t\n^ ()"; /* Chars not allowed in unit name --- also defined in units.c */ char *nonunitends = ".,_"; /* Can't start or end a unit */ char *number_start = ".,0123456789"; /* Can be first char of a number */ @@ -2064,6 +2090,20 @@ } } + /* Check for arbitrary base log */ + + if (!strncmp(name, "log",3)){ + count = strspn(name+3,"1234567890"); + if (count+3 == strlen(name)){ + lvalp->integer=atoi(name+3); + if (lvalp->integer>1){ /* Log base must be larger than 1 */ + comm->location += length; + free(name); + return LOG; + } + } + } + /* Look for function parameter */ if (function_parameter && !strcmp(name,function_parameter)){ diff -Nru units-2.16/parse.y units-2.19/parse.y --- units-2.16/parse.y 2017-09-29 20:11:18.000000000 +0000 +++ units-2.19/parse.y 2019-05-29 00:32:19.000000000 +0000 @@ -1,6 +1,6 @@ /* * parse.y: the parser for GNU units, a program for units conversion - * Copyright (C) 1999-2002, 2007, 2009, 2014, 2017 Free Software + * Copyright (C) 1999-2002, 2007, 2009, 2014, 2017-2018 Free Software * Foundation, Inc * * This program is free software; you can redistribute it and/or modify @@ -100,14 +100,17 @@ return ret; } - -double -logb2(double x) -{ - return log(x)/log(2.0); +int +logunit(struct unittype *theunit, int base) +{ + if ((err=unit2num(theunit))) + return err; + theunit->factor = log(theunit->factor)/log((double)base); + if (errno) + return E_FUNC; + return 0; } - - + int funcunit(struct unittype *theunit, struct function const *fun) { @@ -162,6 +165,7 @@ %token REAL %token UNIT %token REALFUNC +%token LOG %token UNITFUNC %token EXPONENT %token MULTIPLY @@ -190,7 +194,7 @@ %left UNARY %left DIVIDE MULTSTAR %left MULTIPLY MULTMINUS -%nonassoc '(' SQRT CUBEROOT REALFUNC UNIT REAL UNITFUNC FUNCINV MEMERROR BADNUMBER UNITEND LASTUNSET +%nonassoc '(' SQRT CUBEROOT REALFUNC LOG UNIT REAL UNITFUNC FUNCINV MEMERROR BADNUMBER UNITEND LASTUNSET %right EXPONENT %left NUMDIV @@ -244,6 +248,7 @@ | SQRT pexpr { err = rootunit($2,2); CHECK($2); $$=$2;} | CUBEROOT pexpr { err = rootunit($2,3); CHECK($2); $$=$2;} | REALFUNC pexpr { err = funcunit($2,$1);CHECK($2); $$=$2;} + | LOG pexpr { err = logunit($2,$1); CHECK($2); $$=$2;} | UNITFUNC pexpr { err = evalfunc($2,$1,0,0); CHECK($2);$$=$2;} | FUNCINV UNITFUNC pexpr { err = evalfunc($3,$2,1,0); CHECK($3);$$=$3;} | list EXPONENT MULTMINUS list %prec EXPONENT @@ -267,11 +272,16 @@ {"tan", tan, ANGLEIN}, {"ln", log, DIMENSIONLESS}, {"log", log10, DIMENSIONLESS}, - {"log2", logb2, DIMENSIONLESS}, {"exp", exp, DIMENSIONLESS}, {"acos", acos, ANGLEOUT}, {"atan", atan, ANGLEOUT}, {"asin", asin, ANGLEOUT}, + {"sinh", sinh, DIMENSIONLESS}, + {"cosh", cosh, DIMENSIONLESS}, + {"tanh", tanh, DIMENSIONLESS}, + {"asinh", asinh, DIMENSIONLESS}, + {"acosh", acosh, DIMENSIONLESS}, + {"atanh", atanh, DIMENSIONLESS}, {0, 0, 0}}; struct { @@ -305,7 +315,7 @@ const char *inptr; char *name; - char *nonunitchars = "~;+-*/|\t\n^ ()"; /* Chars not allowed in unit name */ + char *nonunitchars = "~;+-*/|\t\n^ ()"; /* Chars not allowed in unit name --- also defined in units.c */ char *nonunitends = ".,_"; /* Can't start or end a unit */ char *number_start = ".,0123456789"; /* Can be first char of a number */ @@ -422,6 +432,20 @@ } } + /* Check for arbitrary base log */ + + if (!strncmp(name, "log",3)){ + count = strspn(name+3,"1234567890"); + if (count+3 == strlen(name)){ + lvalp->integer=atoi(name+3); + if (lvalp->integer>1){ /* Log base must be larger than 1 */ + comm->location += length; + free(name); + return LOG; + } + } + } + /* Look for function parameter */ if (function_parameter && !strcmp(name,function_parameter)){ diff -Nru units-2.16/README units-2.19/README --- units-2.16/README 2017-10-16 00:55:39.000000000 +0000 +++ units-2.19/README 2018-09-13 11:00:35.000000000 +0000 @@ -1,46 +1,128 @@ -GNU 'units' converts between different systems of units. It can -handle multiplicative scale changes. It can also handle nonlinear -conversions such as Celsius to Fahrenheit (which may appear to be -linear but is actually affine). +Overview +======== +GNU 'units' program converts quantities expressed in various systems of +measurement to their equivalents in other systems of measurement. Like +many similar programs, it can handle multiplicative scale changes; but +it can also handle nonlinear conversions such as Fahrenheit to Celsius +(which may appear to be linear but is actually affine). The program can +also perform conversions from and to sums of units, such as converting +between meters and feet plus inches. + +Basic operation is simple: at the 'You have:' prompt, enter the unit +from which you want to convert; at the subsequent 'You want:' prompt, +enter the unit to which you want to convert. For example, + + You have: ft + You want: m + * 0.3048 + / 3.2808399 + +In other words, 1 foot is equal to 0.3048 meter (exactly), and 1 meter +is equal to approximately 3.2808339 feet. + +To quit the program, enter either 'quit' or 'exit' at either the 'You +have:' or 'You want:' prompt. You can also quit by entering Ctrl-C at +any time. ------------------------------------------------------------------- - -Installation +The program's features are described in detail in the user manual. +Building and Installation +========================= General installation instructions appear in the file 'INSTALL'. You should be able to run './configure' followed by 'make'. If you give no options to configure, it will compile units to look for the units -data file in a standard location (probably /usr/local/share). If you -try to use the program without installing you will need to use the -'-f' option. If you don't want to commit to an installation location, -you can invoke configure by typing './configure --enable-path-search'. -Then no path name will be compiled into 'units' and it will search the -current directory and the directories listed in your PATH environment -variable to find the units data file. - -If you are building on Windows with the MKS Toolkit, see the file -'UnitsMKS.pdf'. +data file in a standard location (probably /usr/local/share) and the +currency file in /usr/local/com. -If you are building with Microsoft Visual Studio from the Windows -command prompt, see the file 'UnitsWin'. +If you want to use the program without installing, you will need to use +the '-f' option; if you plan to use the program frequently without +installing, you can avoid having to do this by setting +'UNITSFILE=definitions.units' in the environment. You can also avoid +having to do this by building for a relocatable installation, described +below. + +If you wish to change the locations of the files you can invoke +'./configure' with the option '--prefix=' to set a +different installation location. You may also choose to use +'--sharedstatedir=' to change the location for the currency +file. + +Building for a Relocatable Installation +--------------------------------------- +By default, the location of the units data file is compiled into the +program as an absolute path name, so its location cannot be changed. If +you invoke configure by typing './configure --enable-relocation', the +data file location will be compiled into the program as +'definitions.units', and units will search for the data file in the +following places: + + * In the directory that contains the units executable, typical for + installations on Windows. + + * In /bin/../share/units, where /bin is the + directory that contains the units executable, typical for + installations on Unix-like systems. For example, the default + installation typically places the executable in /usr/local/bin and + the data file in /usr/local/share/units; if you wished, you could + change these locations to /usr/me/bin and /usr/me/share/units + without recompiling the program. + +If configure is run with '--enable-relocation', you can run units +without installing without giving the '-f' option. + +If units is invoked with the '-f' option or the environment variable +UNITSFILE is set, that path is used, and it makes no difference whether +configure was run with the '--enable-relocation' option. +GNU readline Library +-------------------- For full functionality you should have the GNU readline library -installed to provide history and editing of data entry. You can -update currency conversions using the units_cur script which requires -Python and the unidecode module. - -The documentation is available in texinfo, roff, and text format. The -man page is generated automatically from the texinfo documentation. -This man page produces readable results when run through nroff, but it -should probably not be printed with troff or groff--no effort has -been made to ensure that it prints out reasonably. To generate a -printed manual, use 'units.dvi' instead. +installed to provide history and editing of data entry. + +Note that MacOS comes with editline, which is similar to GNU readline, +but not similar enough. When compiling under MacOS the configure +script looks for GNU readline in /opt/local. If you have installed it +somewhere else then invoke configure as follows: + ./configure -I -L +Then the configure script should detect readline and compile it in. + +If you are installing on Windows, readline may not be available; +however, command history and intraline editing are available via the +standard Windows console facilities described in the documentation for +doskey. + +Currency Conversion Updates +--------------------------- +You can update currency conversions using the units_cur Python script; +see the user manual for details. + +Building on Windows +=================== +units can be built from the Windows command prompt using Visual Studio; +see UnitsWin.pdf for details. +units can also be built from the MKS Korn shell using Visual Studio; +see UnitsMKS.pdf for details. + +Documentation +============= +The documentation is provided in texinfo, roff, and text format. The +roff manual page source units.man is generated automatically from the +texinfo documentation; this produces a readable man page when run +through nroff, but most equations are not included. The manual page +formats well for printing or as PDF with groff. A printed manual can +also be generated using 'units.dvi'; use this if you encounter problems +with groff. + +Icons +===== The distribution includes three icons that may be useful for installation in a GUI. Use the icotool command to extract the png files from the .ico files. The icon_ms.png file is suitable for use as a small button. +Incompatibilities with Unix 'units' +=================================== This program has the following incompatibilties with unix 'units': * The '-' character is a subtraction operator rather than a multiply operator by default. @@ -53,6 +135,8 @@ differences. (e.g. 'g' is for gravity in unix 'units' and grams in GNU 'units'.) The comment character has been changed to '#'. +GNU 'units' Extensions +====================== GNU 'units' includes the following extensions: * Multiplication can be written with a '*' if desired. * Exponents can be written with '^' or '**' in units. @@ -61,44 +145,24 @@ * The units data file is extensively commented. * Units which measure reciprocal dimensions can be converted. * Parentheses for grouping are supported. - * Funtions such as sin, cos, and log are supported. + * Functions such as sin, cos, and log are supported. * Roots of units and rational exponents can be computed. * Nonlinear units conversions are supported. * Conversion to lists of units (e.g. feet and inches) is supported ----------------------------------------------------------------------- - -When updating from 1.x to 2.x: - -The name of the personal units file has changed from $HOME/units.dat -to $HOME/.units ($HOME/unitdef.units under Windows). - -The format for nonlinear unit definitions has changed. Run 'units -c' -and add the "units=" keyword in front of any bracketed unit -specifications. - ------------------------------------------------------------------- - -Ports - -Windows: Building with Microsoft Visual Studio - -units can be built from the Windows command prompt using Visual Studio; -see UnitsWin for details. - -units can also be built from the the MKS Korn shell using Visual Studio; -see UnitsMKS for details. - -Windows: Binary Distribution - +Windows Binary Distribution +=========================== A binary distribution for Windows is available at http://ftp.gnu.org/gnu/units/windows/. The executable was built with Microsoft Visual Studio using Makefile.Win and the same source -files included in the source distribution. There is currently no -support for UTF-8 or readline; however, command history and intraline -editing are available via the standard Windows console facilities -described in the documentation for doskey. +files included in the source distribution. The binary version is +usually the same as that of the current source distribution. There is +currently no support for UTF-8 or readline; however, command history and +intraline editing are available via the standard Windows console +facilities described in the documentation for doskey. +Other Ports +=========== A port of units 1.87 to Windows is available from the http://gnuwin32.sourceforge.net/packages/units.htm This port includes readline support. @@ -107,9 +171,9 @@ is available on SourceForge at http://units-in-java.sourceforge.net/ Two versions are available for Android. Steve Pomeroy has a version -based on the the above Java version that you can obtain at -http://staticfree.info/projects/units/ and Keith Flowers has compiled -the C code for Android: http://apps.keithflower.org/?page_id=6 +based on the above Java version that you can obtain at http:// +staticfree.info/projects/units/ and Keith Flowers has compiled the C +code for Android: http://apps.keithflower.org/?page_id=6 A Perl version was written by Bob Walton and can be accessed either as a units converting web form or as perl source code @@ -125,6 +189,17 @@ ----------------------------------------------------------------------------- +When updating from 1.x to 2.x: + +The name of the personal units file has changed from $HOME/units.dat +to $HOME/.units ($HOME/unitdef.units under Windows). + +The format for nonlinear unit definitions has changed. Run 'units -c' +and add the "units=" keyword in front of any bracketed unit +specifications. + +----------------------------------------------------------------------------- + Ideas the future (may or may not happen): * Bundle up the units conversion stuff into a library. @@ -152,10 +227,8 @@ As it stands, "per" is hard coded into the parser. * Represent uncertainties in values in the database. ------------------------------------------------------------------------------ - Acknowledgements - +================ This program owes a lot to Jeff Conrad who made many helpful suggestions, found numerous bugs, and helped me to find the definitions of obscure units. Chris Madsen also made some valuable contributions. diff -Nru units-2.16/texi2man units-2.19/texi2man --- units-2.16/texi2man 2014-01-22 21:42:33.000000000 +0000 +++ units-2.19/texi2man 2019-04-03 01:20:10.000000000 +0000 @@ -4,9 +4,11 @@ # Jeff Conrad. # Script to translate a texinfo file into an nroff/troff manual page. -# last revision: 20 January 2014 Jeff Conrad +# last revision: 30 March 2019 Jeff Conrad -$version="1.01s"; +$thisprog = $0; +$thisprog =~ s/.*[\/\\]//; +$version="1.01w"; $html=0; $example=0; @@ -21,7 +23,7 @@ $args=($#ARGV < 0) ? "stdin" : "@ARGV"; printf(".\\\"Do not edit this file. It was created from %s\n", $args); -printf(".\\\"using texi2man version %s on %s", $version, `date`); +printf(".\\\"using %s version %s on %s", $thisprog, $version, `date`); while(<>) { @@ -33,9 +35,28 @@ print; next; } + if (/\@c\s+man\s+program/) { + chop; + s/\@c\s+man\s+program\s+//; + $program = $_; + next; + } if (s/\@c man //) { print; + if (/AUTHOR/) { + $errors = 0; + if (! $author) { + printf(STDERR "%s: missing '\@author'\n", $thisprog); + $errors++; + } + if (! $program) { + printf(STDERR "%s: missing '\@c man program'\n", $thisprog); + $errors++; + } + if ($errors) { exit; } + else { printf(".I %s\nwas written by %s\n", $program, $author); } + } if (/\.TH/) { add_extensions(); } next; } @@ -46,11 +67,19 @@ if (/\@c ifman\s*(.*)/) { $doman=1; $manprefix = $1; next; } if (/\@c end ifman/) { $doman=0; $manprefix = ""; next; } + if (/^\@c [^m]/) { next; } + if (/^\\input/) { next; } if (/^\*/) { next; } if (/^START-INFO-DIR-ENTRY/) { next; } if (/^END-INFO-DIR-ENTRY/) { next; } + if (/\@author/) { + chop; + s/\@author\s+//; + $author = $_; + next; + } if (/\@titlepage/) { $title=1; next; } if (/\@end titlepage/) { $title=0; next; } if (/\@tex/) { $tex=1; next; } @@ -59,8 +88,11 @@ if (/\@end ignore/) { $ignore=0; next; } if (/\@ifhtml/) { $html=1; next; } if (/\@end ifhtml/) { $html=0; next; } + if (/\@html/) { $html=1; next; } + if (/\@end html/) { $html=0; next; } if (!$doman && ($ignore || $html || $title || $tex)) { next; } - if (/\@codequoteundirected/) { next; } + if (/\@set codequoteundirected/) { print ".aQ\n"; next; } + if (/\@clear codequoteundirected/) { print ".aE\n"; next; } s/\@\*$/\n\.br/g; s/^\@\*/.br/g; @@ -71,6 +103,10 @@ s/\@w\{}/\@no_break_space\{}/g; s/\@backslashchar\{}/\\e/g; + # opening and closing double quotes + s/``(\S)/\\\*(lQ$1/g; + s/(\S)''/$1\\\*(rQ/g; + # ellipsis, defined in extensions s/\@dots\{}/\\*(El/g; @@ -133,13 +169,18 @@ s/\@w\{([^}]*)}/\@no_break_word\{$1}/g; } - s/\@minus\{}/\\-/g; + # leave minus (dash) lists so they can be recognized later + if (! /^\@itemize/) { s/\@minus\{}/\\-/g; } s/\@copyright\{}/\\(co/g; s/\@noindent//; s/\@\{/{/g; s/\@}/}/g; s/\@\@/@/g; s/---/\\(em/g; + # allowable line break escape: groff only? + s/\@\//\\:/g; + s/^\@raggedright/.na/; + s/^\@end raggedright/.ad b/; s/\@in_sgl_quotes\{([^}]+)}/`$1'/g; s/\@in_dbl_quotes\{([^}]+)}/\"$1\"/g; @@ -187,41 +228,78 @@ s/(\S)\\(?!(\s|f[RIBP]|f\([A-Z]{2}))/$1\\e/g; } # some versions of n/troff don't have \(en, so use \- - # don't replace double hyphens in C[IQW] macros; assume true en - # dashes will be closed up to previous word - s/([^" ]+)--/$1\\-/g; + # don't replace double hyphens in C[IQW] macros; assume true + # en dashes will be closed up to previous word + s/([^" ]+?)--/$1\\-/g; s/\@value\{([^\s]+)}/$value{$1}/eg; if (/\@set\s+([^\s]+)\s+(.*)$/) { $value{$1} = $2; next; } if (/\@clear\s+([^\s]+)\s+(.*)$/) { delete $value{$1}; next; } - # works only for @item and @itemx as used in units(1) - if (/\@itemx (.*)/) + # tables of command-line options as used in units(1) + if (/\@table (.*)/) { $intable = 1; next; } + if (/\@end *table/) { - $samp = $1; - # add hair space to visually separate the hyphens in roman type - $samp =~ s/--/-\\^-/; - $samp =~ s/-([[:alnum:]])/-\\^$1/; - if (!$diditem) - { printf(".TP\n.BR \"$samp\""); } - else - { printf(" \", \" \"$samp\""); } - $diditem=1; next; + $intable = 0; + if ($in_taggedlist == 1) { $in_taggedlist = 0; } + next; } - elsif ($diditem) { printf("\n"); $diditem=0; } - if (/\@item (.*)/) + if ($intable == 1) { - $samp = $1; - # add hair space to visually separate the hyphens in roman type - $samp =~ s/--/-\\^-/; - $samp =~ s/-([[:alnum:]])/-\\^$1/; - printf("%s.TP\n%s.BR \"$samp\"", $manprefix, $manprefix); - $diditem=1; + if (/\@itemx (.*)/) + { + $samp = $1; + # add hair space to visually separate the hyphens in roman type + $samp =~ s/--/-\\^-/; + $samp =~ s/-([[:alnum:]])/-\\^$1/; + if (!$diditem) + { printf(".TP\n.BR \"$samp\""); } + else + { printf(" \", \" \"$samp\""); } + $diditem=1; + $new_paragraph = ""; + next; + } + elsif ($diditem) { printf("\n"); $diditem=0; } + if (/\@item (.*)/) + { + $in_taggedlist = 1; + $samp = $1; + # add hair space to visually separate the hyphens in roman type + $samp =~ s/--/-\\^-/; + $samp =~ s/-([[:alnum:]])/-\\^$1/; + printf("%s.TP\n%s.BR \"$samp\"", $manprefix, $manprefix); + $diditem=1; + $new_paragraph = ""; + next; + } + } + # output a paragraph macro unless already done with a TP macro above + if ($new_paragraph) + { + printf("%s\n", $new_paragraph); + $justdidlp = 1; + $new_paragraph = ""; + } + + # unordered list: bullet or minus + if (/^\@itemize *$/ || /^\@itemize +@(bullet|minus)(\{})?/) + { + if ($1 =~ "minus") { $listmark = "\\-"; } + else { $listmark = "\\(bu"; } + $in_ulist = 1; next; } + if ($in_ulist == 1 && /^\@end +itemize/) { $in_ulist = 0; next; } + if ($in_ulist == 1) + { + if (/^\@item *$/) { printf("%s.IP \\h'1n'%s 4n\n", $manprefix, $listmark); } + + } if (s/\@chapter (.*)/.SH \U$1\E/) { + if (/GNU FREE DOCUMENTATION/) { next; } # restore proper case on font switches s/\\FR/\\fR/g; s/\\FI/\\f(BI/g; # chapter headings (SH in man) are bold @@ -256,11 +334,18 @@ if ($example) { s/\\\s*$/\\e\n/ }; + # blank line: new paragraph; don't output until we see if @item or @itemx follows if (!$example && /^\s*$/ && !$doman) { if ($justdidlp) { next; } - printf(".PP\n"); - $justdidlp=1; + if ($in_taggedlist == 1) + { + $new_paragraph = ".IP"; + } + else + { + $new_paragraph = ".PP"; + } next; } @@ -278,73 +363,174 @@ sub add_extensions { - # ensure that ASCII circumflex U+005E (^) is not remapped with groff printf(".\\\"\n"); - printf(".\\\" ensure that ASCII circumflex U+005E (^) is not remapped with groff\n"); - printf(".if \\n(.g .tr ^\\(ha\n"); + printf(".if \\n(.g \\{\\\n"); + printf(". \\\" ensure that ASCII circumflex U+005E (^) is not remapped\n"); + printf(". tr ^\\(ha\n"); + printf(". \\\" override translation in troffrc\n"); + printf(". ie '\\*[.T]'utf8' .tr `\\(oq'\\(cq\n"); + printf(". \\\" override mapping of ` to 60h with Tascii; assume\n"); + printf(". \\\" we don't need a backquote for an example\n"); + printf(". el .if n .tr `'\n"); + printf(".\\}\n"); # ellipsis: space periods with troff but not with nroff printf(".\\\" ellipsis: space periods with troff but not with nroff\n"); printf(".if n .ds El \\&...\n"); printf(".if t .ds El \\&.\\ .\\ .\n"); - # constant-width font + # bullet: use '*' rather than 'o' for ASCII/Latin1; override groff's + # translation to MIDDLE DOT for others + printf(".if n \\{\\\n"); + printf(". tr \\(bu\*\n"); + printf(". \\\" override translation to MIDDLE DOT\n"); + printf(". if \\n(.g .if '\\*(.T'utf8' .tr \\(bu\\(bu\n"); + printf(". if \\n(.g .if '\\*(.T'cp1252' .tr \\(bu\\(bu\n"); + printf(". if \\n(.g .if '\\*(.T'ansi' .tr \\(bu\\(bu\n"); + printf(".\\}\n"); + printf(".\\\"\n"); printf(".\\\" Extensions to man macros\n"); printf(".\\\"\n"); + + printf(".\\\" set handling of single quotes: 0=>straight, >0=>left and right\n"); + printf(".nr tQ 0\n"); + printf(".\\\" groff only\n"); + printf(".if '\\\*(.T'utf8' .nr tQ 1\n"); + printf(".\\\" non-standard devices: Windows code page 1252\n"); + printf(".if '\\\*(.T'cp1252' .nr tQ 1\n"); + printf(".if '\\\*(.T'ansi' .nr tQ 1\n"); + + # constant-width font printf(".\\\" Constant-width font\n"); printf(".de CW\n"); printf(".hy 0\n"); - # just single quotes with nroff + printf(".\\\" nroff can't show CW font, so enclose in single quotes\n"); printf(".if n \\{\\\n"); - printf(".ie \\\\n(.\$>2 \\&\\\\\$1'\\\\\$2'\\\\\$3\n"); - printf(".el \\&'\\\\\$1'\\\\\$2\n"); + printf(". ie \\\\n(.g \\{\\\n"); + printf(". \\\" use proper opening and closing single quotes\n"); + printf(". ie \\\\n(tQ>0 \\{\\\n"); + printf(". ie \\\\n(.\$>2 \\&\\\\\$1\\(oq\\\\\$2\\(cq\\\\\$3\n"); + printf(". el \\&\\(oq\\\\\$1\\(cq\\\\\$2\n"); + printf(". \\}\n"); + printf(". \\\" ensure neutral single quotes with Tascii\n"); + printf(". el \\{\\\n"); + printf(". ie \\\\n(.\$>2 \\&\\\\\$1\\(aq\\\\\$2\\(aq\\\\\$3\n"); + printf(". el \\&\\(aq\\\\\$1\\(aq\\\\\$2\n"); + printf(". \\}\n"); + printf(". \\}\n"); + printf(". \\\" legacy nroff doesn't have 'aq', so use ' and hope for the best\n"); + printf(". el \\{\\\n"); + printf(". ie \\\\n(.\$>2 \\&\\\\\$1'\\\\\$2'\\\\\$3\n"); + printf(". el \\&'\\\\\$1'\\\\\$2\n"); + printf(". \\}\n"); printf(".\\}\n"); - # constant-width font with troff + printf(".\\\" troff can change fonts, so no need for quotes\n"); printf(".if t \\{\\\n"); - printf(".ie \\\\n(.\$>2 \\&\\\\\$1\\f(CW\\\\\$2\\fR\\\\\$3\n"); - printf(".el \\&\\f(CW\\\\\$1\\fR\\\\\$2\n"); + printf(". ie \\\\n(.\$>2 \\&\\\\\$1\\f(CW\\\\\$2\\fR\\\\\$3\n"); + printf(". el \\&\\f(CW\\\\\$1\\fR\\\\\$2\n"); printf(".\\}\n"); printf(".hy 14\n"); printf("..\n"); - # constant-width oblique font printf(".\\\" Constant-width oblique font\n"); printf(".de CI\n"); printf(".hy 0\n"); - # single quotes with nroff + printf(".\\\" nroff can't show CW font, so enclose in single quotes\n"); printf(".if n \\{\\\n"); - printf(".ie \\\\n(.\$>2 \\&\\\\\$1'\\fI\\\\\$2\\fR'\\\\\$3\n"); - printf(".el \\&'\\fI\\\\\$1\\fR'\\\\\$2\n"); + printf(". ie \\\\n(.g \\{\\\n"); + printf(". \\\" use proper opening and closing single quotes\n"); + printf(". ie \\\\n(tQ \\{\\\n"); + printf(". ie \\\\n(.\$>2 \\&\\\\\$1\\(oq\\fI\\\\\$2\\fR\\(cq\\\\\$3\n"); + printf(". el \\&\\(oq\\fI\\\\\$1\\fR\\(cq\\\\\$2\n"); + printf(". \\}\n"); + printf(". \\\" ensure neutral single quotes with Tascii\n"); + printf(". el \\{\\\n"); + printf(". ie \\\\n(.\$>2 \\&\\\\\$1\\(aq\\fI\\\\\$2\\fR\\(aq\\\\\$3\n"); + printf(". el \\&\\(aq\\fI\\\\\$1\\fR\\(aq\\\\\$2\n"); + printf(". \\}\n"); + printf(". \\}\n"); + printf(". \\\" legacy nroff doesn't have 'aq', so use ' and hope for the best\n"); + printf(". el \\{\n"); + printf(". ie \\\\n(.\$>2 \\&\\\\\$1'\\fI\\\\\$2\\fR'\\\\\$3\n"); + printf(". el \\&'\\fI\\\\\$1\\fR'\\\\\$2\n"); + printf(". \\}\n"); printf(".\\}\n"); - # constant-width oblique font with troff + printf(".\\\" troff can change fonts, so no need for quotes\n"); printf(".if t \\{\\\n"); - printf(".ie \\\\n(.\$>2 \\&\\\\\$1\\f(CI\\\\\$2\\fR\\\\\$3\n"); - printf(".el \\&\\f(CI\\\\\$1\\fR\\\\\$2\n"); + printf(". ie \\\\n(.\$>2 \\&\\\\\$1\\f(CI\\\\\$2\\fR\\\\\$3\n"); + printf(". el \\&\\f(CI\\\\\$1\\fR\\\\\$2\n"); printf(".\\}\n"); printf(".hy 14\n"); printf("..\n"); - # constant-width font with quotes with troff - printf(".\\\" Constant-width font with quotes\n"); + printf(".\\\" Constant-width font with quotes with nroff and troff\n"); printf(".de CQ\n"); printf(".hy 0\n"); - # just single quotes with nroff printf(".if n \\{\\\n"); - printf(".ie \\\\n(.\$>2 \\&\\\\\$1'\\\\\$2'\\\\\$3\n"); - printf(".el \\&'\\\\\$1'\\\\\$2\n"); + printf(". ie \\\\n(.g \\{\\\n"); + printf(". \\\" use proper opening and closing single quotes\n"); + printf(". ie \\\\n(tQ \\{\\\n"); + printf(". ie \\\\n(.\$>2 \\&\\\\\$1\\(oq\\\\\$2\\(cq\\\\\$3\n"); + printf(". el \\&\\(oq\\\\\$1\\(cq\\\\\$2\n"); + printf(". \\}\n"); + printf(". \\\" ensure neutral single quotes with Tascii\n"); + printf(". el \\{\\\n"); + printf(". ie \\\\n(.\$>2 \\&\\\\\$1\\(aq\\\\\$2\\(aq\\\\\$3\n"); + printf(". el \\&\\(aq\\\\\$1\\(aq\\\\\$2\n"); + printf(". \\}\n"); + printf(". \\}\n"); + printf(". \\\" legacy nroff doesn't have 'aq', so use ' and hope for the best\n"); + printf(". el \\{\\\n"); + printf(". ie \\\\n(.\$>2 \\&\\\\\$1'\\\\\$2'\\\\\$3\n"); + printf(". el \\&'\\\\\$1'\\\\\$2\n"); + printf(". \\}\n"); printf(".\\}\n"); - # constant-width font with troff printf(".if t \\{\\\n"); - # quotes passed as literal text encoded as \(fm - # make it a double quote because groff converts ` and ' to opening and - # closing quotes - printf(".ie \\\\n(.\$>2 \\&\\\\\$1`\\f(CW\\\\\$2\\fR'\\\\\$3\n"); - printf(".el \\&`\\f(CW\\\\\$1\\fR'\\\\\$2\n"); + printf(". ie \\\\n(.g \\{\\\n"); + printf(". ie \\\\n(.\$>2 \\&\\\\\$1\\(oq\\f(CW\\\\\$2\\fR\\(cq\\\\\$3\n"); + printf(". el \\&\\(oq\\f(CW\\\\\$1\\fR\\(cq\\\\\$2\n"); + printf(". \\}\n"); + printf(". \\\" legacy troff doesn't have 'oq' or 'cq'\n"); + printf(". el \\{\\\n"); + printf(". ie \\\\n(.\$>2 \\&\\\\\$1`\\f(CW\\\\\$2\\fR'\\\\\$3\n"); + printf(". el \\&`\\f(CW\\\\\$1\\fR'\\\\\$2\n"); + printf(". \\}\n"); printf(".\\}\n"); printf(".hy 14\n"); printf("..\n"); + # equivalent of \@set codequoteundirected + printf(".\\\" equivalent of \@set codequoteundirected\n"); + printf(".de aQ\n"); + printf(".if \\\\n(.g .tr '\\(aq\n"); + printf("..\n"); + printf(".\\\" equivalent of \@clear codequoteundirected\n"); + printf(".de aE\n"); + printf(".if \\\\n(.g \\{ .ie \\\\n(tQ>0 .tr '\\(cq\n"); + printf(".el .tr '' \\}\n"); + printf("..\n"); + + # opening and closing double quotes + printf(".\\\" opening and closing double quotes\n"); + printf(".\\\" groff: true opening and closing quotes\n"); + printf(".ie \\n(.g \\{\\\n"); + printf(". ds lQ \\(lq\n"); + printf(". ds rQ \\(rq\n"); + printf(".\\}\n"); + printf(".el \\{\\\n"); + printf(".\\\" legacy nroff: ASCII neutral double quotes\n"); + printf(". ie n \\{\\\n"); + printf(". ds lQ \"\"\n"); + printf(". ds rQ \"\"\n"); + printf(". \\}\n"); + printf(".\\\" legacy troff: adjacent opening and closing single quotes\n"); + printf(". el \\{\\\n"); + printf(". ds lQ ``\n"); + printf(". ds rQ ''\n"); + printf(". \\}\n"); + printf(".\\}\n"); + # Display Start--indent, no fill printf(".\\\" Display start\n"); printf(".de DS\n"); @@ -448,7 +634,7 @@ $ndx++; } # get rid of the closing brace for the @ command. This should - # always be true unless theres an internal brace mismatch ... + # always be true unless there's an internal brace mismatch ... if (substr($line, $ndx - 1, 1) eq '}' ) { substr($line, $ndx - 1, 1, ''); } @@ -459,5 +645,3 @@ return $line; } - - diff -Nru units-2.16/units.c units-2.19/units.c --- units-2.16/units.c 2017-10-31 09:48:11.000000000 +0000 +++ units-2.19/units.c 2019-05-30 09:53:20.000000000 +0000 @@ -1,8 +1,8 @@ -#define VERSION "2.16" +#define VERSION "2.19" /* * units, a program for units conversion - * Copyright (C) 1996, 1997, 1999, 2000-2007, 2009, 2011-2017 + * Copyright (C) 1996, 1997, 1999, 2000-2007, 2009, 2011-2018 * Free Software Foundation, Inc * * This program is free software; you can redistribute it and/or modify @@ -23,6 +23,12 @@ * This program was written by Adrian Mariano (adrianm@gnu.org) */ +#define LICENSE "\ +Copyright (C) 2018 Free Software Foundation, Inc.\n\ +GNU Units comes with ABSOLUTELY NO WARRANTY.\n\ +You may redistribute copies of GNU Units\n\ +under the terms of the GNU General Public License." + #define _XOPEN_SOURCE 600 #if defined (_WIN32) && defined (_MSC_VER) @@ -98,14 +104,6 @@ # define PATHSEP ':' #endif -#ifndef EOFCHAR -# ifdef _WIN32 -# define EOFCHAR "Z" -# else -# define EOFCHAR "D" -# endif -#endif - #define PRIMITIVECHAR '!' /* Character that marks irreducible units */ #define COMMENTCHAR '#' /* Comments marked by this character */ #define COMMANDCHAR '!' /* Unit database commands marked with this */ @@ -113,9 +111,7 @@ /* char in rl_basic_word_break_characters */ /* and in nonunitchars defined in parse.y */ #define FUNCSEPCHAR ';' /* Separates forward and inverse definitions */ -#define HELPCOMMAND "help" /* Command to request help at prompt */ -#define SEARCHCOMMAND "search" /* Command to request text search of units */ -#define UNITMATCH "?" /* Command to request conformable units */ +#define REDEFCHAR '+' /* Mark unit as redefinition to suppress warning message */ #define DEFAULTPAGER "more" /* Default pager program */ #define DEFAULTLOCALE "en_US" /* Default locale */ #define MAXINCLUDE 5 /* Max depth of include files */ @@ -136,16 +132,15 @@ #define HOME_UNITS_ENV "MYUNITSFILE" /* Personal units file environment var */ -#define LICENSE "\ -Copyright (C) 2017 Free Software Foundation, Inc.\n\ -GNU Units comes with ABSOLUTELY NO WARRANTY.\n\ -You may redistribute copies of GNU Units\n\ -under the terms of the GNU General Public License." - - #define NOERROR_KEYWORD "noerror " /* The trailing space is important */ #define CO_NOARG -1 +#define HELPCOMMAND "help" /* Command to request help at prompt */ +#define SEARCHCOMMAND "search" /* Command to request text search of units */ +#define UNITMATCH "?" /* Command to request conformable units */ +char *exit_commands[]={"quit","exit",0}; +char *all_commands[]={"quit","exit",HELPCOMMAND,SEARCHCOMMAND,UNITMATCH,0}; + /* Key words for function definitions */ struct { char *word; @@ -161,8 +156,9 @@ #define FN_RANGE 2 #define FN_NOERROR 3 -char *builtins[] = {"sin", "cos", "tan","ln", "log", "log2", "exp", - "acos", "atan", "asin", "sqrt", "cuberoot", "per", 0}; +char *builtins[] = {"sin", "cos", "tan","ln", "log", "exp", + "acos", "atan", "asin", "sqrt", "cuberoot", "per", + "sinh", "cosh", "tanh", "asinh", "atanh", "acosh", 0}; struct { char *format; /* printf() format specification for numeric output */ @@ -200,6 +196,7 @@ char *unitsfiles[MAXFILES+1]; /* Null terminated list of units file names */ char *logfilename=0; /* Filename for logging */ FILE *logfile=0; /* File for logging */ +char *promptprefix=0; /* Prefix added to prompt */ char *progname; /* Used in error messages */ char *fullprogname; /* Full path of program; printversion() uses */ char *progdir; /* Used to find supporting files */ @@ -368,6 +365,36 @@ } +void +logprintf(const char *format, ...) +{ + va_list args; + + va_start(args, format); + vprintf(format, args); + va_end(args); + if (logfile) { + va_start(args, format); + vfprintf(logfile, format, args); + va_end(args); + } +} + +void +logputchar(char c) +{ + putchar(c); + if (logfile) fputc(c, logfile); +} + +void +logputs(const char *s) +{ + fputs(s, stdout); + if (logfile) fputs(s, logfile); +} + + /* Look for a subscript in the input string. A subscript starts with '_' and is followed by a sequence of only digits (matching the regexp "_[0-9]+"). The function returns 1 if it finds a subscript @@ -778,8 +805,16 @@ int checkunitname(char *name, int linenum, char *file, FILE *errfile) { + char nonunitchars[] = "~;+-*/|^)"; /* Also defined in parse.y with a few more characters */ char **ptr; + char *cptr; + if ((cptr=strpbrk(name, nonunitchars))){ + if (errfile) fprintf(errfile, + "%s: unit '%s' in units file '%s' on line %d ignored. It contains invalid character '%c'\n", + progname, name, file, linenum, *cptr); + return 1; + } if (strchr(digits, name[0])){ if (errfile) fprintf(errfile, "%s: unit '%s' in units file '%s' on line %d ignored. It starts with a digit\n", @@ -793,13 +828,19 @@ progname, name, file, linenum); return 1; } + for(ptr=all_commands;*ptr;ptr++) + if (!strcmp(name, *ptr)){ + if (errfile) fprintf(errfile, + "%s: unit name '%s' in file '%s' on line %d may be hidden by command with the same name.\n", + progname, name, file, linenum); + } return 0; } int newunit(char *unitname, char *unitdef, int *count, int linenum, - char *file,FILE *errfile) + char *file,FILE *errfile, int redefine) { struct unitlist *uptr; unsigned hashval; @@ -825,7 +866,7 @@ return E_BADFILE; if ((uptr=ulookup(unitname))) { /* Is it a redefinition? */ - if (flags.unitcheck && errfile) + if (flags.unitcheck && errfile && !redefine) fprintf(errfile, "%s: unit '%s' defined on line %d of '%s' is redefined on line %d of '%s'.\n", progname, unitname, uptr->linenumber,uptr->file, @@ -853,7 +894,7 @@ int newprefix(char *unitname, char *unitdef, int *count, int linenum, - char *file,FILE *errfile) + char *file,FILE *errfile, int redefine) { struct prefixlist *pfxptr; unsigned pval; @@ -863,7 +904,7 @@ return E_BADFILE; if ((pfxptr = plookup(unitname)) /* already there: redefinition */ && !strcmp(pfxptr->name, unitname)){ - if (flags.unitcheck && errfile) + if (flags.unitcheck && errfile && !redefine) fprintf(errfile, "%s: prefix '%s-' defined on line %d of '%s' is redefined on line %d of '%s'.\n", progname, unitname, pfxptr->linenumber,pfxptr->file, @@ -1077,7 +1118,7 @@ int newfunction(char *unitname, char *unitdef, int *count, - int linenum, char *file,FILE *errfile) + int linenum, char *file,FILE *errfile, int redefine) { char *start, *end, *inv, *forward_dim, *inverse_dim, *first, *second; double *domain_min, *domain_max, *range_min, *range_max; @@ -1236,7 +1277,7 @@ return E_BADFILE; } if ((funcentry=fnlookup(unitname))){ - if (flags.unitcheck && errfile) + if (flags.unitcheck && errfile && !redefine) fprintf(errfile, "%s: function '%s' defined on line %d of '%s' is redefined on line %d of '%s'.\n", progname, unitname, funcentry->linenumber,funcentry->file, @@ -1283,7 +1324,7 @@ int newtable(char *unitname,char *unitdef, int *count, - int linenum, char *file,FILE *errfile) + int linenum, char *file,FILE *errfile, int redefine) { char *start, *end; char *tableunit; @@ -1362,7 +1403,7 @@ start=end+strspn(end," ,"); } if ((funcentry=fnlookup(unitname))){ - if (flags.unitcheck && errfile) + if (flags.unitcheck && errfile && !redefine) fprintf(errfile, "%s: unit '%s' defined on line %d of '%s' is redefined on line %d of '%s'.\n", progname, unitname, funcentry->linenumber,funcentry->file, @@ -1523,8 +1564,8 @@ { FILE *unitfile; char *line = 0, *lineptr, *unitdef, *unitname, *permfile; - int len, linenum, linebufsize, goterr, retcode; - int locunitcount, locprefixcount, locfunccount; + int linenum, linebufsize, goterr, retcode; + int locunitcount, locprefixcount, locfunccount, redefinition; int wronglocale = 0; /* If set then we are currently reading data */ int inlocale = 0; /* for the wrong locale so we should skip it */ int in_utf8 = 0; /* If set we are reading utf8 data */ @@ -1657,14 +1698,26 @@ if (in_utf8 && !utf8mode) continue; if (wronglocale || wrongvar) continue; + if (!strcmp(unitname,"prompt")){ + unitname = strtok(0,""); /* Rest of the line */ + if (promptprefix) + free(promptprefix); + if (!unitname) + promptprefix=0; + else + promptprefix = dupstr(unitname); + continue; + } if (!strcmp(unitname,"message")){ - unitname = strtok(0,""); /* Rest of the line */ - if (!flags.quiet && unitname) - puts(unitname); + unitname = strtok(0,""); /* Rest of the line */ + if (!flags.quiet){ + if (unitname) logputs(unitname); + logputchar('\n'); + } continue; } - else if (!strcmp(unitname,"set")) { - unitname = strtok(0," "); + else if (!strcmp(unitname,"set")) { + unitname = strtok(0," "); unitdef = strtok(0," "); if (!unitname) readerror(errfile, @@ -1744,16 +1797,20 @@ continue; } - len = strlen(unitname); + if (*unitname == REDEFCHAR){ + unitname++; + redefinition=1; + } else + redefinition=0; - if (unitname[len - 1] == '-'){ /* it's a prefix definition */ + if (lastchar(unitname) == '-'){ /* it's a prefix definition */ if (newprefix(unitname,unitdef,&locprefixcount,linenum, - permfile,errfile)) + permfile,errfile,redefinition)) goterr=1; } else if (strchr(unitname,'[')){ /* table definition */ retcode=newtable(unitname,unitdef,&locfunccount,linenum, - permfile,errfile); + permfile,errfile,redefinition); if (retcode){ if (retcode != E_BADFILE){ fclose(unitfile); @@ -1765,11 +1822,11 @@ } else if (strchr(unitname,'(')){ /* function definition */ if (newfunction(unitname,unitdef,&locfunccount,linenum, - permfile,errfile)) + permfile,errfile,redefinition)) goterr = 1; } else { /* ordinary unit definition */ - if (newunit(unitname,unitdef,&locunitcount,linenum,permfile,errfile)) + if (newunit(unitname,unitdef,&locunitcount,linenum,permfile,errfile,redefinition)) goterr = 1; } } @@ -1816,36 +1873,6 @@ } -void -logprintf(const char *format, ...) -{ - va_list args; - - va_start(args, format); - vprintf(format, args); - va_end(args); - if (logfile) { - va_start(args, format); - vfprintf(logfile, format, args); - va_end(args); - } -} - -void -logputchar(char c) -{ - putchar(c); - if (logfile) fputc(c, logfile); -} - -void -logputs(const char *s) -{ - fputs(s, stdout); - if (logfile) fputs(s, logfile); -} - - /* Print out a unit */ void @@ -3673,6 +3700,7 @@ putchar('\n'); exit(EXIT_SUCCESS); } + replacectrlchars(*buffer); valid = strwidth(*buffer)>=0; if (!valid) printf("Error: %s\n",invalid_utf8); @@ -3684,6 +3712,7 @@ putchar('\n'); exit(EXIT_SUCCESS); } + replacectrlchars(*buffer); #endif } @@ -3700,13 +3729,18 @@ while (!valid){ if (*buffer) free(*buffer); *buffer = readline(query); - valid = !*buffer || strwidth(*buffer)>=0; - if (!valid) + if (*buffer) + replacectrlchars(*buffer); + if (!*buffer || strwidth(*buffer)>=0) + valid=1; + else printf("Error: %s\n",invalid_utf8); } #else if (*buffer) free(*buffer); *buffer = readline(query); + if (*buffer) + replacectrlchars(*buffer); #endif if (*buffer && **buffer) add_history(*buffer); if (!*buffer){ @@ -4365,6 +4399,7 @@ -t, --terse terse output (--strict --compact --quiet --one-line)\n\ -r, --round round last element of unit list output to an integer\n\ -U, --unitsfile show units data filename and exit\n\ + -u, --units specify a CGS unit system (gauss[ian]|esu|emu)\n\ -V, --version show version, data filenames (with -t: version only)\n\ -I, --info show version, files, and program properties\n", DEFAULTTYPE,DEFAULTPRECISION); @@ -4507,7 +4542,7 @@ } -char *shortoptions = "VIUvqechSstf:o:d:mnpr1l:L:" +char *shortoptions = "VIUu:vqechSstf:o:d:mnpr1l:L:" #ifdef READLINE "H:" #endif @@ -4541,6 +4576,7 @@ {"strict",no_argument,&flags.strictconvert, 1}, {"terse",no_argument, 0, 't'}, {"unitsfile", no_argument, 0, 'U'}, + {"units", required_argument, 0, 'u'}, {"verbose", no_argument, &flags.verbose, 2}, {"verbose-check", no_argument, &flags.unitcheck, 2}, {"version", no_argument, 0, 'V'}, @@ -4558,6 +4594,7 @@ int optchar, optindex; int ind; int doprintversion=0; + char *unitsys=0; while ( -1 != (optchar = @@ -4646,6 +4683,11 @@ showunitsfile(); exit(EXIT_SUCCESS); break; + case 'u': + unitsys = optarg; + for(ind=0;unitsys[ind];ind++) + unitsys[ind] = tolower(unitsys[ind]); + break; case 'h': usage(); exit(EXIT_SUCCESS); @@ -4670,6 +4712,10 @@ exit(EXIT_SUCCESS); } + /* command-line option overwrites environment */ + if (unitsys) + setenv("UNITS_SYSTEM", unitsys, 1); + if (flags.unitcheck) { if (optind != argc){ fprintf(stderr, @@ -4773,7 +4819,7 @@ UNITSEPCHAR) for errors. All units must be parseable and conformable to each other. Returns 0 on success and 1 on failure. - I an error is found then print an error message on stdout. A + If an error is found then print an error message on stdout. A pointer ('^') will be printed to mark the error. The promptlen parameter should be set to the printing width of the prompt string so that the pointer is correctly aligned. @@ -5243,11 +5289,15 @@ char commandbuf[1000]; /* Hopefully this is enough overkill as no bounds */ int unitline; /* checking is performed. */ char *file; + char **exitptr; if (have && !strcmp(str, UNITMATCH)){ tryallunits(have,0); return 1; } + for(exitptr=exit_commands;*exitptr;exitptr++) + if (!strcmp(str, *exitptr)) + exit(EXIT_SUCCESS); if (startswith(str, SEARCHCOMMAND)){ str+=strlen(SEARCHCOMMAND); if (!emptystr(str) && *str != ' ') @@ -5282,7 +5332,7 @@ example converts the cube root of a bushel to a list %sft;in\n\ of semicolon-separated units. 1 ft + 0.9 in\n\ \n\ -To quit from units type Ctrl-%s or Ctrl-C. %s2 btu + 450 ft lbf\n\ +To quit from units type 'quit' or 'exit'. %s2 btu + 450 ft lbf\n\ %s(kg^2/s)/(day lb/m^2)\n\ At the '%s' prompt type '%s' to get a * 1.0660684e+08\n\ list of conformable units. At either prompt you / 9.3802611e-09\n\ @@ -5295,7 +5345,6 @@ QUERYHAVE, QUERYWANT, QUERYWANT, QUERYHAVE,QUERYWANT,QUERYHAVE,QUERYWANT, -EOFCHAR, QUERYHAVE,QUERYWANT, QUERYWANT, UNITMATCH, @@ -5449,6 +5498,7 @@ while(!feof(map)){ if (!fgets(name,80,map)) break; + lastchar(name) = 0; value=strchr(name,'#'); if (value) *value=0; value=strchr(name,'\t'); @@ -5579,6 +5629,9 @@ #ifdef _WIN32 if (!strcmp(homeunitsfile,".units")) homeunitsfile = "unitdef.units"; + localemap = findlocalemap(0); + if (localemap) + remaplocale(localemap); #endif interactive = processargs(argc, argv, &havestr, &wantstr); @@ -5629,12 +5682,6 @@ } } -#ifdef _WIN32 - localemap = findlocalemap(0); - if (localemap) - remaplocale(localemap); -#endif - for(unitfileptr=unitsfiles;*unitfileptr;unitfileptr++){ readerr = readunits(*unitfileptr, stderr, &unitcount, &prefixcount, &funccount, 0); @@ -5651,8 +5698,19 @@ if (flags.quiet) queryhave = querywant = ""; /* No prompts are being printed */ else { - queryhave = QUERYHAVE; - querywant = QUERYWANT; + if (!promptprefix){ + queryhave = QUERYHAVE; + querywant = QUERYWANT; + } else { + queryhave = (char *)mymalloc(strlen(promptprefix)+strlen(QUERYHAVE)+1, + "(main)"); + querywant = (char *)mymalloc(strlen(promptprefix)+strlen(QUERYWANT)+1, + "(main)"); + strcpy(queryhave, promptprefix); + strcat(queryhave, QUERYHAVE); + memset(querywant, ' ', strlen(promptprefix)); + strcpy(querywant+strlen(promptprefix), QUERYWANT); + } printf("%d units, %d prefixes, %d nonlinear units\n\n", unitcount, prefixcount,funccount); } diff -Nru units-2.16/units_cur units-2.19/units_cur --- units-2.16/units_cur 2017-11-01 01:41:59.000000000 +0000 +++ units-2.19/units_cur 2018-09-15 20:30:09.000000000 +0000 @@ -1,18 +1,53 @@ #!/usr/bin/python # +# units_cur for units, a program for updated currency exchange rates +# +# Copyright (C) 2017-2018 +# Free Software Foundation, Inc +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +# +# +# This program was written by Adrian Mariano (adrianm@gnu.org) +# + # For Python 2 & 3 compatibility from __future__ import absolute_import, division, print_function # # -version = '4.1' +version = '5.0' -# 30 October 2017 +# Version 5.0: +# +# Rewrite to support multiple different data sources due to disappearance +# of the Yahoo feed. Includes support for base currency selection. +# +# Version 4.3: 20 July 2018 +# +# Validate rate data from server +# +# Version 4.2: 18 April 2018 +# +# Handle case of empty/malformed entry returned from the server +# +# Version 4.1: 30 October 2017 # # Fixed to include USD in the list of currency codes. # -# Version 4 -# 2 October 2017 +# Version 4: 2 October 2017 # # Complete rewrite to use Yahoo YQL API due to removal of TimeGenie RSS feed. # Switched to requests library using JSON. One program now runs under @@ -29,10 +64,17 @@ outfile_name = 'currency.units' +# valid metals + +validmetals = ['silver','gold','platinum'] + +PRIMITIVE = '! # Base unit, the primitive unit of currency' + # This exchange rate table lists the currency ISO 4217 codes, their # long text names, and any fixed definitions. If the definition is # empty then units_cur will query the server for a value. +rate_index = 1 currency = OrderedDict([ ('ATS', ['austriaschilling', '1|13.7603 euro']), ('BEF', ['belgiumfranc', '1|40.3399 euro']), @@ -57,13 +99,14 @@ ('BGN', ['bulgarialev', '1|1.9558 euro']), ('BAM', ['bosniaconvertiblemark','germanymark']), ('KMF', ['comorosfranc', '1|491.96775 euro']), - ('XOF', ['westafricanfranc', '1|655.957 euro']), + ('XOF', ['westafricafranc', '1|655.957 euro']), ('XPF', ['cfpfranc', '1|119.33 euro']), - ('XAF', ['centralafricancfafranc','1|655.957 euro']), + ('XAF', ['centralafricacfafranc','1|655.957 euro']), ('AED', ['uaedirham','']), ('AFN', ['afghanafghani','']), ('ALL', ['albanialek','']), ('AMD', ['armeniadram','']), + ('ANG', ['antillesguilder','']), ('AOA', ['angolakwanza','']), ('ARS', ['argentinapeso','']), ('AUD', ['australiadollar','']), @@ -83,7 +126,7 @@ ('BTN', ['bhutanngultrum','']), ('BWP', ['botswanapula','']), ('BYN', ['belarusruble','']), - ('BYR', ['oldbelarusruble','10000 BYN']), + ('BYR', ['oldbelarusruble','1|10000 BYN']), ('BZD', ['belizedollar','']), ('CAD', ['canadadollar','']), ('CDF', ['drcfranccongolais','']), @@ -101,7 +144,7 @@ ('DZD', ['algeriadinar','']), ('EGP', ['egyptpound','']), ('ERN', ['eritreanakfa','']), - ('ETB', ['ethiopianbirr','']), + ('ETB', ['ethiopiabirr','']), ('EUR', ['euro','']), ('FJD', ['fijidollar','']), ('FKP', ['falklandislandspound','']), @@ -138,10 +181,9 @@ ('KZT', ['kazakhstantenge','']), ('LAK', ['laokip','']), ('LBP', ['lebanonpound','']), - ('LKR', ['srilankanrupee','']), + ('LKR', ['srilankarupee','']), ('LRD', ['liberiadollar','']), - ('LTL', ['lithuanialita','']), - ('LVL', ['latvialat','']), + ('LSL', ['lesotholoti','']), ('LYD', ['libyadinar','']), ('MAD', ['moroccodirham','']), ('MDL', ['moldovaleu','']), @@ -150,13 +192,14 @@ ('MMK', ['myanmarkyat','']), ('MNT', ['mongoliatugrik','']), ('MOP', ['macaupataca','']), - ('MRO', ['mauritaniaouguiya','']), + ('MRO', ['mauritaniaoldouguiya','1|10 MRU']), + ('MRU', ['mauritaniaouguiya', '']), ('MUR', ['mauritiusrupee','']), ('MVR', ['maldiverufiyaa','']), ('MWK', ['malawikwacha','']), ('MXN', ['mexicopeso','']), ('MYR', ['malaysiaringgit','']), - ('MZN', ['mozambicanmetical','']), + ('MZN', ['mozambiquemetical','']), ('NAD', ['namibiadollar','']), ('NGN', ['nigerianaira','']), ('NIO', ['nicaraguacordobaoro','']), @@ -186,7 +229,9 @@ ('SLL', ['sierraleoneleone','']), ('SOS', ['somaliaschilling','']), ('SRD', ['surinamedollar','']), - ('STD', ['saotome&principedobra','']), + ('SSP', ['southsudanpound','']), + ('STD', ['saotome&principeolddobra','']), + ('STN', ['saotome&principedobra','']), ('SVC', ['elsalvadorcolon','']), ('SYP', ['syriapound','']), ('SZL', ['swazilandlilangeni','']), @@ -201,15 +246,15 @@ ('TZS', ['tanzaniashilling','']), ('UAH', ['ukrainehryvnia','']), ('UGX', ['ugandaschilling','']), - ('USD', ['unitedstatesdollar', 'US$']), + ('USD', ['US$', '']), ('UYU', ['uruguaypeso','']), ('UZS', ['uzbekistansum','']), - ('VEF', ['venezuelabolivar','']), - ('VEB', ['venezuelaoldbolivar', '1000 VEF']), + ('VEF', ['venezuelabolivarfuerte','']), + ('VES', ['venezuelabolivarsoberano','']), ('VND', ['vietnamdong','']), ('VUV', ['vanuatuvatu','']), ('WST', ['samoatala','']), - ('XAF', ['centralafricancfafranc','']), + ('XAF', ['centralafricacfafranc','']), ('XCD', ['eastcaribbeandollar','']), ('XDR', ['specialdrawingrights','']), ('YER', ['yemenrial','']), @@ -218,6 +263,147 @@ ('ZWL', ['zimbabwedollar','']), ]) +def validfloat(x): + try: + float(x) + return True + except ValueError: + return False + +def addrate(verbose,form,code,rate): + if code not in currency.keys(): + if (verbose): + stderr.write('Got unknown currency with code {}\n'.format(code)) + else: + if not currency[code][rate_index]: + if validfloat(rate): + currency[code][rate_index] = form.format(rate) + else: + stderr.write('Got invalid rate "{}" for currency "{}"\n'.format( + rate, code)) + elif verbose: + if currency[code][rate_index] != form.format(rate): + stderr.write('Got value "{}" for currency "{}" but ' + 'it is already defined as {}\n'.format(rate, code, + currency[code][rate_index])) + +def getjson(address,args=None): + try: + res = requests.get(address,args) + res.raise_for_status() + return(res.json()) + except requests.exceptions.RequestException as e: + stderr.write('Error connecting to currency server:\n{}.\n'.format(e)) + exit(1) + +######################################################## +# +# Connect to floatrates for currency update +# + +def floatrates(verbose,base,dummy): + webdata = getjson('https://www.floatrates.com/daily/'+base+'.json') + for index in webdata: + entry = webdata[index] + if 'rate' not in entry or 'code' not in entry: # Skip empty/bad entries + if verbose: + stderr.write('Got bad entry from server: '+str(entry)+'\n') + else: + addrate(verbose,'{} '+base,entry['code'],entry['inverseRate']) + currency[base][rate_index] = PRIMITIVE + return('FloatRates ('+base+' base)') + +######################################################## +# +# Connect to European central bank site +# + +def eubankrates(verbose,base,dummy): + if verbose and base!='EUR': + stderr.write('European bank uses euro for base currency. Specified base {} ignored.\n'.format(base)) + import xml.etree.ElementTree as ET + try: + res=requests.get('https://www.ecb.europa.eu/stats/eurofxref/eurofxref-daily.xml') + res.raise_for_status() + data = ET.fromstring(res.content)[2][0] + except requests.exceptions.RequestException as e: + stderr.write('Error connecting to currency server:\n{}.\n'. + format(e)) + exit(1) + for entry in data.iter(): + if entry.get('time'): + continue + rate = entry.get('rate') + code = entry.get('currency') + if not rate or not code: # Skip empty/bad entries + if verbose: + stderr.write('Got bad entry from server, code {} and rate {}\n'.format(code,rate)) + else: + addrate(verbose,'1|{} euro', code, rate) + currency['EUR'][rate_index]=PRIMITIVE + return('the European Central Bank (euro base)') + +######################################################## +# +# Connect to fixer.io (requires API key) +# +# Free API key does not allow changing base currency +# With free key only euro base is supported, and https is not allowed +# + +def fixer(verbose,base,key): + if not key: + stderr.write('API key required for this source\n') + exit(1) + if verbose and base!='EUR': + stderr.write('Fixer uses euro for base currency. Specified base {} ignored.\n'.format(base)) + webdata = getjson('http://data.fixer.io/api/latest', {'access_key':key}) + if not webdata['success']: + stderr.write('Currency server error: '+webdata['error']['info']) + exit(1) + for code in webdata['rates']: + addrate(verbose,'1|{} euro', code, webdata['rates'][code]) + currency['EUR'][rate_index] = PRIMITIVE + return('Fixer (euro base)') + +######################################################## +# +# Connect to openexchangerates (requires API key) +# +# Free API key does not allow changing the base currency +# + +def openexchangerates(verbose,base,key): + if not key: + stderr.write('API key required for this source\n') + exit(1) + if verbose and base!='USD': + stderr.write('Open Exchange Rates uses US dollar for base currency. Specified base {} ignored.\n'.format(base)) + webdata = getjson('https://openexchangerates.org/api/latest.json', + {'app_id':key} + ) + for code in webdata['rates']: + addrate(verbose,'1|{} US$', code, webdata['rates'][code]) + currency['USD'][rate_index] = PRIMITIVE + return('open exchange rates (USD base)') + +####################################################### +# +# list of valid source names and corresponding functions +# + +sources = { + 'floatrates': floatrates, + 'eubank' : eubankrates, + 'fixer' : fixer, + 'openexchangerates': openexchangerates, +} + +####################################################### +# +# Argument Processing +# + ap = ArgumentParser( description="Update currency information for 'units' " "into the specified filename or if no filename is " @@ -245,59 +431,43 @@ help='display details when fetching currency data', ) -outfile_name = ap.parse_args().output_file -verbose = ap.parse_args().verbose +ap.add_argument('-s','--source',choices=list(sources.keys()), + default='floatrates', + help='set currency data source', +) -try: - res = requests.get('http://finance.yahoo.com/webservice/v1/symbols' - '/allcurrencies/quote?format=json') - res.raise_for_status() - webdata = res.json()['list']['resources'] -except requests.exceptions.RequestException as e: - stderr.write('Error connecting to currency server:\n{}.\n'. - format(e)) - exit(1) - -rates = [ data['resource']['fields']['price'] for data in webdata] -codes = [ data['resource']['fields']['symbol'][0:3] for data in webdata] +ap.add_argument('-b','--base',default='USD', + help='set the base currency (when allowed by source). BASE should be a 3 letter ISO currency code, e.g. USD. The specified currency will be the primitive currency unit used by units. Only the floatrates source supports this option.', +) -rate_index = 1 +ap.add_argument('-k','--key',default='', + help='set API key for sources that require it' +) -for (code,rate) in zip(codes,rates): - if code not in currency.keys(): - if (verbose): - stderr.write('Got unknown currency with code {}\n'.format(code)) - else: - if not currency[code][rate_index]: - currency[code][rate_index] = '1|{} US$'.format(rate) - elif verbose: - stderr.write('Got value "{}" for currency "{}" but ' - 'it is already defined\n'.format(rate, code)) +args = ap.parse_args() +outfile_name = args.output_file +verbose = args.verbose +source = args.source +base = args.base +apikey = args.key +if base not in currency.keys(): + stderr.write('Base currency {} is not a known currency code.\n'.format(base)) + exit(1) + +######################################################## +# +# Fetch currency data from specified curerncy source +# + +sourcename = sources[source](verbose,base,apikey) + # Delete currencies where we have no rate data -for code in currency.keys(): +for code in list(currency.keys()): if not currency[code][rate_index]: if verbose: - stderr.write('No data for {}'.format(code)) + stderr.write('No data for {}\n'.format(code)) del currency[code] - -try: - req = requests.get('http://services.packetizer.com/spotprices/?f=json') - req.raise_for_status() - metals = req.json() -except requests.exceptions.RequestException as e: - stderr.write('Error connecting to spotprices server:\n{}\n'.format(e)) - exit(1) - -del metals['date'] - -try: - req = requests.get('http://services.packetizer.com/btc/?f=json') - req.raise_for_status() - bitcoin = req.json() -except requests.exceptions.RequestException as e: - stderr.write('Error connecting to bitcoin server:\n{}\n'.format(e)) - exit(1) cnames = [currency[code][0] for code in currency.keys()] crates = [currency[code][1] for code in currency.keys()] @@ -305,40 +475,69 @@ codestr = '\n'.join('{:23}{}'. format(code, name) for (code,name) in zip(currency.keys(), cnames)) -datestr = date.today().isoformat() - maxlen = max(len(name) for name in cnames) + 2 ratestr = '\n'.join( '{:{}}{}'.format(name, maxlen, rate) for (name, rate) in zip(cnames, crates) ) -ozzystr = '\n'.join('{:19}{} US$/troyounce'.format( - metal + 'price', - price, - ) for metal, price in metals.items()) +####################################################### +# +# Get precious metals data and bitcoin +# + +metals = getjson('https://services.packetizer.com/spotprices',{'f':'json'}) +bitcoin = getjson('https://services.packetizer.com/btc',{'f':'json'}) + +metallist = ['']*len(validmetals) +for metal, price in metals.items(): + if metal in validmetals: + metalindex = validmetals.index(metal) + if validfloat(price): + if not metallist[metalindex]: + metallist[validmetals.index(metal)] = '{:19}{} US$/troyounce'.format( + metal + 'price', price) + elif verbose: + stderr.write('Got value "{}" for metal "{}" but ' + 'it is already defined\n'.format(price,metal)) + else: + stderr.write('Got invalid rate "{}" for metal "{}"\n'.format(price,metal)) + elif metal != 'date' and verbose: # Don't print a message for the "date" entry + stderr.write('Got unknown metal "{}" with value "{}"\n'.format(metal,price)) +metalstr = '\n'.join(metallist) -bitcoinstr = '{:{}}{} US$ # From services.packetizer.com/btc\n'.format( +if validfloat(bitcoin['usd']): + bitcoinstr = '{:{}}{} US$ # From services.packetizer.com/btc\n'.format( 'bitcoin',maxlen,bitcoin['usd']) +else: + stderr.write('Got invalid bitcoin rate "{}"\n', bitcoint['usd']) + bitcointstr='' +####################################################### +# +# Format output and write the currency file +# + +datestr = date.today().isoformat() + outstr = ( """# ISO Currency Codes {codestr} -# Currency exchange rates from Yahoo Finance (finance.yahoo.com) +# Currency exchange rates source -!message Currency exchange rates from finance.yahoo.com on {datestr} +!message Currency exchange rates from {sourcename} on {datestr} {ratestr} {bitcoinstr} # Precious metals prices from Packetizer (services.packetizer.com/spotprices) -{ozzystr} +{metalstr} -""".format(codestr=codestr, datestr=datestr, ratestr=ratestr, ozzystr=ozzystr, - bitcoinstr=bitcoinstr) +""".format(codestr=codestr, datestr=datestr, ratestr=ratestr, metalstr=metalstr, + bitcoinstr=bitcoinstr, sourcename=sourcename) ).replace('\n', linesep) try: Binary files /tmp/tmp5EHtQ4/72Ux5uwBEZ/units-2.16/units.dvi and /tmp/tmp5EHtQ4/0mofb4A4hK/units-2.19/units.dvi differ diff -Nru units-2.16/units.info units-2.19/units.info --- units-2.16/units.info 2017-11-01 02:16:28.000000000 +0000 +++ units-2.19/units.info 2019-05-29 00:32:21.000000000 +0000 @@ -1,11 +1,10 @@ -This is units.info, produced by makeinfo version 6.4.90 from -units.texinfo. +This is units.info, produced by makeinfo version 6.5 from units.texinfo. -This manual is for GNU Units (version 2.16), which performs units +This manual is for GNU Units (version 2.18), which performs units conversions and units calculations. Copyright (C) 1996, 1997, 1999, 2000, 2001, 2002, 2004, 2005, 2007, -2011-2017 Free Software Foundation, Inc. +2011-2019 Free Software Foundation, Inc. Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, @@ -26,8 +25,8 @@ This manual describes the 'units' command for units conversion and how you can use it as a powerful scientific calculator that keeps track of -units. This is Edition 2.14 of 'The Units Conversion Manual' for -'units' Version 2.16. +units. This is Edition 2.16 of 'The Units Conversion Manual' for +'units' Version 2.18. * Menu: @@ -38,8 +37,10 @@ * Unit Expressions:: Forming compound units. * Nonlinear Conversions:: Nonlinear unit conversions (e.g., temperature). * Unit Lists:: Conversion to sums of units (e.g., feet and inches). +* Using CGS Units:: Using CGS units: Gaussian, ESU, or EMU * Logging Calculations:: Logging conversions and calculations in a file. * Invoking Units:: Command line options. +* Output Styles:: Different ways units can print the output. * Defining Your Own Units:: Adding your own unit definitions * Numeric Output Format:: How to change the output format * Localization:: How to define and use regional unit names. @@ -101,8 +102,8 @@ 2 Interacting with 'units' ************************** -To invoke units for interactive use, type 'units' at your shell prompt. -The program will print something like this: +To invoke 'units' for interactive use, type 'units' at your shell +prompt. The program will print something like this: Currency exchange rates from www.timegenie.com on 2014-03-05 2860 units, 109 prefixes, 85 nonlinear units @@ -113,11 +114,10 @@ converting _from_. For example, if you want to convert ten meters to feet, type '10 meters'. Next, 'units' will print 'You want:'. You should type the units you want to convert _to_. To convert to feet, you -would type 'feet'. If the 'readline' library was compiled in then -will complete unit names. *Note Readline Support::, for more -information about 'readline'. To quit the program under Unix, press - or . Under Windows, press or ; with -the latter, you may also need to press . +would type 'feet'. If the 'readline' library was compiled in, then + will complete unit names. *Note Readline Support::, for more +information about 'readline'. To quit the program type 'quit' or 'exit' +at either prompt. The result will be displayed in two ways. The first line of output, which is marked with a '*' to indicate multiplication, gives the result @@ -266,12 +266,19 @@ and then exit. The output tells you that 2 liters is about 2.1 quarts, or alternatively that a quart is about 0.47 times 2 liters. + 'units' does not require a space between a numerical value and the +unit, so the previous example can be given as + + units 2liters quarts + +to avoid having to quote the first argument. + If the conversion is successful, then 'units' will return success -(zero) to the calling environment. If you enter non-conformable units +(zero) to the calling environment. If you enter non-conformable units, then 'units' will print a message giving the reduced form of each unit and it will return failure (nonzero) to the calling environment. - When you invoke 'units' with only one argument, it will print out the + When you invoke 'units' with only one argument, it will print the definition of the specified unit. It will return failure if the unit is not defined and success if the unit is defined. @@ -348,9 +355,9 @@ percent. By default if 'units' runs in the 'en_GB' locale you will get the British volume measures. If it runs in the 'en_US' locale you will get the US volume measures. In other locales the default values are the -US definitions. If you wish to force different definitions then set the -environment variable 'UNITS_ENGLISH' to either 'US' or 'GB' to set the -desired definitions independent of the locale. +US definitions. If you wish to force different definitions, then set +the environment variable 'UNITS_ENGLISH' to either 'US' or 'GB' to set +the desired definitions independent of the locale. Before 1959, the value of a yard (and other units of measure defined in terms of it) differed slightly among English-speaking countries. In @@ -619,9 +626,9 @@ ====================== Several built-in functions are provided: 'sin', 'cos', 'tan', 'ln', -'log', 'log2', 'exp', 'acos', 'atan' and 'asin'. The 'sin', 'cos', and -'tan' functions require either a dimensionless argument or an argument -with dimensions of angle. +'log', 'exp', 'acos', 'atan', 'asin', 'cosh', 'sinh', 'tanh', 'acosh', +'asinh', and 'atanh'. The 'sin', 'cos', and 'tan' functions require +either a dimensionless argument or an argument with dimensions of angle. You have: sin(30 degrees) You want: @@ -639,6 +646,30 @@ inverse trigonometric functions return arguments with dimensions of angle. + The 'ln' and 'log' functions give natural log and log base 10 +respectively. To obtain logs for any integer base, enter the desired +base immediately after 'log'. For example, to get log base 2 you would +write 'log2' and to get log base 47 you could write 'log47'. + + You have: log2(32) + You want: + Definition: 5 + You have: log3(32) + You want: + Definition: 3.1546488 + You have: log4(32) + You want: + Definition: 2.5 + You have: log32(32) + You want: + Definition: 1 + You have: log(32) + You want: + Definition: 1.50515 + You have: log10(32) + You want: + Definition: 1.50515 + If you wish to take roots of units, you may use the 'sqrt' or 'cuberoot' functions. These functions require that the argument have the appropriate root. You can obtain higher roots by using fractional @@ -749,7 +780,7 @@ Delta P = (8/pi^2) rho f L (Q^2 / d^5) -where \Delta P is the pressure drop, \rho is the mass density, f is the +where Delta P is the pressure drop, rho is the mass density, f is the (dimensionless) friction factor, L is the length of the pipe, Q is the volumetric flow rate, and d is the pipe diameter. It might be desired to have the equation in the form @@ -811,9 +842,9 @@ with a space, giving it a higher precedence than division. When '-' is used as a unary operator it negates its operand. -Regardless of the 'units' options, if '-' appears after '(' or after '+' -then it will act as a negation operator. So you can always compute 20 -degrees minus 12 minutes by entering '20 degrees + -12 arcmin'. You +Regardless of the 'units' options, if '-' appears after '(' or after +'+', then it will act as a negation operator. So you can always compute +20 degrees minus 12 minutes by entering '20 degrees + -12 arcmin'. You must use this construction when you define new units because you cannot know what options will be in force when your definition is processed. @@ -985,7 +1016,7 @@ Defining Nonlinear Units::.  -File: units.info, Node: Unit Lists, Next: Logging Calculations, Prev: Nonlinear Conversions, Up: Top +File: units.info, Node: Unit Lists, Next: Using CGS Units, Prev: Nonlinear Conversions, Up: Top 7 Unit Lists: Conversion to Sums of Units ***************************************** @@ -1229,9 +1260,248 @@ 4;0;0;3.6280454  -File: units.info, Node: Logging Calculations, Next: Invoking Units, Prev: Unit Lists, Up: Top +File: units.info, Node: Using CGS Units, Next: Logging Calculations, Prev: Unit Lists, Up: Top + +8 Using CGS Units +***************** + +* Menu: + +* Specifying CGS Units:: How to specify the desired CGS units +* CGS Units Systems:: The various CGS units systems +* Conversions Between Systems:: Conversions between units in different systems +* Prompt Prefix:: The prompt prefix shows specified CGS units + +The SI--an extension of the MKS (meter-kilogram-second) system--has +largely supplanted the older CGS (centimeter-gram-second) system, but +CGS units are still used in a few specialized fields, especially in +physics where they lead to a more elegant formulation of Maxwell's +equations. Conversions between SI and CGS involving mechanical units +are straightforward, involving powers of 10 (e.g., 1 m = 100 cm). +Conversions involving electromagnetic units are more complicated, and +'units' supports three different systems of CGS units: electrostatic +units (ESU), electromagnetic units (EMU), and the Gaussian system. The +differences between these systems arise from different choices made for +proportionality constants in electromagnetic equations. Coulomb's law +gives electrostatic force between two charges separated by a distance r: + + F = k_C q_1 q_2 / r^2. + + +Ampere's law gives the electromagnetic force per unit length between two +current-carrying conductors separated by a distance r: + + F/l = 2 k_A I_1 I_2 / r. + + +The two constants, k_C and k_A, are related by the square of the speed +of light: k_A = k_C / c^2. + + In the SI, the constants have dimensions, and an additional base +unit, the ampere, measures electric current. The CGS systems do not +define new base units, but express charge and current as derived units +in terms of mass, length, and time. In the ESU system, the constant for +Coulomb's law is chosen to be unity and dimensionless, which defines the +unit of charge. In the EMU system, the constant for Ampere's law is +chosen to be unity and dimensionless, which defines a unit of current. +The Gaussian system usually uses the ESU units for charge and current; +it chooses another constant so that the units for the electric and +magnetic fields are the same. + + The dimensions of electrical quantities in the various CGS systems +are different from the SI dimensions for the same units; strictly, +conversions between these systems and SI are not possible. But units in +different systems relate to the same physical quantities, so there is a +_correspondence_ between these units. The 'units' program defines the +units so that you can convert between corresponding units in the various +systems. + + +File: units.info, Node: Specifying CGS Units, Next: CGS Units Systems, Up: Using CGS Units + +8.1 Specifying CGS Units +======================== + +The CGS definitions involve cm^(1/2) and g^(1/2) which is problematic +because 'units' does not normally support fractional roots of base +units. The '--units' ('-u') option allows selection of a CGS unit +system and works around this restriction by introducing base units for +the square roots of length and mass: 'sqrt_cm' and 'sqrt_g'. The +centimeter then becomes 'sqrt_cm^2' and the gram, 'sqrt_g^2'. This +allows working from equations using the units in the CGS system, and +enforcing dimensional conformity within that system. Recognized +arguments to the '--units' option are 'gauss[ian]', 'esu', 'emu', and +'si'; the argument is case insensitive. The default mode for 'units' is +SI units; the only effect of giving 'si' with the '--units' option is to +prepend '(SI)' to the 'You have:' prompt. Giving an unrecognized system +generates a warning, and 'units' uses SI units. + + The changes resulting from the '--units' option are actually +controlled by the 'UNITS_SYSTEM' environment variable. If you +frequently work with one of the supported CGS units systems, you may set +this environment variable rather than giving the '--units' option at +each invocation. As usual, an option given on the command line +overrides the setting of the environment variable. For example, if you +would normally work with Gaussian units but might occasionally work with +SI, you could set 'UNITS_SYSTEM' to 'gaussian' and specify SI with the +'--units' option. Unlike the argument to the '--units' option, the +value of 'UNITS_SYSTEM' _is_ case sensitive, so setting a value of 'EMU' +will have no effect other than to give an error message and set SI +units. + + The CGS definitions appear as conditional settings in the standard +units data file, which you can consult for more information on how these +units are defined, or on how to define an alternate units system. + + +File: units.info, Node: CGS Units Systems, Next: Conversions Between Systems, Prev: Specifying CGS Units, Up: Using CGS Units + +8.2 CGS Units Systems +===================== + +The ESU system derives the electromagnetic units from its unit of +charge, the statcoulomb, which is defined from Coulomb's law. The +statcoulomb equals dyne^(1/2) cm or cm^(3/2) g^(1/2) s^(-1). The unit +of current, the statampere, is statcoulomb sec, analogous to the +relationship in SI. Other electrical units are then derived in a manner +similar to that for SI units; the units use the SI names prefixed by +'stat-', e.g., 'statvolt' or 'statV'. The prefix 'st-' is also +recognized (e.g., 'stV'). + + The EMU system derives the electromagnetic units from its unit of +current, the abampere, which is defined in terms of Ampere's law. The +abampere is equal to dyne^(1/2) or cm^(1/2) g^(1/2) s^(-1). The unit of +charge, the abcoulomb, is abampere sec, again analogous to the SI +relationship. Other electrical units are then derived in a manner +similar to that for SI units; the units use the SI names prefixed by +'ab-', e.g., 'abvolt' or 'abV'. The magnetic field units include the +gauss, the oersted and the maxwell. + + The Gaussian units system, which was also known as the Symmetric +System, uses the same charge and current units as the ESU system (e.g., +'statC', 'statA'); it differs by defining the magnetic field so that it +has the same units as the electric field. The resulting magnetic field +units are the same ones used in the EMU system: the gauss, the oersted +and the maxwell. + + +File: units.info, Node: Conversions Between Systems, Next: Prompt Prefix, Prev: CGS Units Systems, Up: Using CGS Units + +8.3 Conversions Between Different Systems +========================================= + +The CGS systems define units that measure the same thing but may have +conflicting dimensions. Furthermore, the dimensions of the +electromagnetic CGS units are never compatible with SI. But if you +measure charge in two different systems you have measured the same +physical thing, so there is a _correspondence_ between the units in the +different systems, and 'units' supports conversions between +corresponding units. When running with SI, 'units' defines all of the +CGS units in terms of SI. When you select a CGS system, 'units' defines +the SI units and the other CGS system units in terms of the system you +have selected. + + (Gaussian) You have: statA + You want: abA + * 3.335641e-11 + / 2.9979246e+10 + (Gaussian) You have: abA + You want: sqrt(dyne) + conformability error + 2.9979246e+10 sqrt_cm^3 sqrt_g / s^2 + 1 sqrt_cm sqrt_g / s + +In the above example, 'units' converts between the current units statA +and abA even though the abA, from the EMU system, has incompatible +dimensions. This works because in Gaussian mode, the abA is defined in +terms of the statA, so it does not have the correct definition for EMU; +consequently, you cannot convert the abA to its EMU definition. + + One challenge of conversion is that because the CGS system has fewer +base units, quantities that have different dimensions in SI may have the +same dimension in a CGS system. And yet, they may not have the same +conversion factor. For example, the unit for the E field and B fields +are the same in the Gaussian system, but the conversion factors to SI +are quite different. This means that correct conversion is only +possible if you keep track of what quantity is being measured. You +cannot convert statV/cm to SI without indicating which type of field the +unit measures. To aid in dimensional analysis, 'units' defines various +dimension units such as LENGTH, TIME, and CHARGE to be the appropriate +dimension in SI. The electromagnetic dimensions such as B_FIELD or +E_FIELD may be useful aids both for conversion and dimensional analysis +in CGS. You can convert them to or from CGS in order to perform SI +conversions that in some cases will not work directly due to dimensional +incompatibilities. This example shows how the Gaussian system uses the +same units for all of the fields, but they all have different conversion +factors with SI. + + (Gaussian) You have: statV/cm + You want: E_FIELD + * 29979.246 + / 3.335641e-05 + (Gaussian) You have: statV/cm + You want: B_FIELD + * 0.0001 + / 10000 + (Gaussian) You have: statV/cm + You want: H_FIELD + * 79.577472 + / 0.012566371 + (Gaussian) You have: statV/cm + You want: D_FIELD + * 2.6544187e-07 + / 3767303.1 + +The next example shows that the oersted cannot be converted directly to +the SI unit of magnetic field, A/m, because the dimensions conflict. We +cannot redefine the ampere to make this work because then it would not +convert with the statampere. But you can still do this conversion as +shown below. + + (Gaussian) You have: oersted + You want: A/m + conformability error + 1 sqrt_g / s sqrt_cm + 29979246 sqrt_cm sqrt_g / s^2 + (Gaussian) You have: oersted + You want: H_FIELD + * 79.577472 + / 0.012566371 + + +File: units.info, Node: Prompt Prefix, Prev: Conversions Between Systems, Up: Using CGS Units + +8.4 Prompt Prefix +================= + +If a unit system is specified with the '--units' option, the selected +system's name is prepended to the 'You have:' prompt as a reminder, +e.g., + + (Gaussian) You have: stC + You want: + Definition: statcoulomb = sqrt(dyne) cm = 1 sqrt_cm^3 sqrt_g / s + +You can suppressed the prefix by including a line + + !prompt + +with no argument in a site or personal units data file. The prompt can +be conditionally suppressed by including such a line within '!var' ... +'!endvar' constructs, e.g., + + !var UNITS_SYSTEM gaussian gauss + !prompt + !endvar + +This might be appropriate if you normally use Gaussian units and find +the prefix distracting but want to be reminded when you have selected a +different CGS system. + + +File: units.info, Node: Logging Calculations, Next: Invoking Units, Prev: Using CGS Units, Up: Top -8 Logging Calculations +9 Logging Calculations ********************** The '--log' option allows you to save the results of calculations in a @@ -1302,10 +1572,10 @@ option is ignored when 'units' is used non-interactively.  -File: units.info, Node: Invoking Units, Next: Defining Your Own Units, Prev: Logging Calculations, Up: Top +File: units.info, Node: Invoking Units, Next: Output Styles, Prev: Logging Calculations, Up: Top -9 Invoking 'units' -****************** +10 Invoking 'units' +******************* You invoke 'units' like this: @@ -1318,7 +1588,9 @@ FROM-UNIT appears on the command line, 'units' will display the definition of that unit and exit. Units specified on the command line may need to be quoted to protect them from shell interpretation and to -group them into two arguments. *Note Command Line Use::. +group them into two arguments. Note also that the '--quiet' option is +enabled by default if you specify FROM-UNIT on the command line. *Note +Command Line Use::. The default behavior of 'units' can be changed by various options given on the command line. In most cases, the options may be given in @@ -1467,20 +1739,6 @@ usual rules of algebra: the precedence of '*' is the same as the precedence of '/', so that '1/2*3' will equal '3/2'. -'--compact' - Give compact output featuring only the conversion factor. This - turns off the '--verbose' option. - -'-q' -'--quiet' -'--silent' - Suppress prompting of the user for units and the display of - statistics about the number of units loaded. - -'-n' -'--nolists' - Disable conversion to unit lists. - '-r' '--round' When converting to a combination of units given by a unit list, @@ -1504,31 +1762,6 @@ cup', a result equivalent to 1 1/2 cups will always be shown as '2 * 3|4 cup' whether or not the '--show-factor' option is given. -'-s' -'--strict' - Suppress conversion of units to their reciprocal units. For - example, 'units' will normally convert hertz to seconds because - these units are reciprocals of each other. The strict option - requires that units be strictly conformable to perform a - conversion, and will give an error if you attempt to convert hertz - to seconds. - -'-1' -'--one-line' - Give only one line of output (the forward conversion). Do not - print the reverse conversion. If a reciprocal conversion is - performed then 'units' will still print the "reciprocal conversion" - line. - -'-t' -'--terse' - Give terse output when converting units. This option can be used - when calling 'units' from another program so that the output is - easy to parse. This option has the combined effect of these - options: '--strict' '--quiet' '--one-line' '--compact'. When - combined with '--version' it produces a display showing only the - program name and version number. - '-v' '--verbose' Give slightly more verbose output when converting units. When @@ -1570,14 +1803,61 @@ Print the location of the default units data file and exit; if the file cannot be found, print "Units data file not found". +'-u (gauss[ian]|esu|emu)' +'--units (gauss[ian]|esu|emu)' + Specify a CGS units system: Gaussian, ESU, or EMU. + '-l LOCALE' '--locale LOCALE' - Print the information given with the '--version' option, show the Force a specified locale such as 'en_GB' to get British definitions by default. This overrides the locale determined from system settings or environment variables. *Note Locale::, for a description of locale format. +'-n' +'--nolists' + Disable conversion to unit lists. + +'-s' +'--strict' + Suppress conversion of units to their reciprocal units. For + example, 'units' will normally convert hertz to seconds because + these units are reciprocals of each other. The strict option + requires that units be strictly conformable to perform a + conversion, and will give an error if you attempt to convert hertz + to seconds. + +'-1' +'--one-line' + Give only one line of output (the forward conversion); do not print + the reverse conversion. If a reciprocal conversion is performed, + then 'units' will still print the "reciprocal conversion" line. + +'-t' +'--terse' + Print only a single conversion factor. This option can be used + when calling 'units' from another program so that the output is + easy to parse. This option has the combined effect of these + options: '--strict' '--quiet' '--one-line' '--compact'. When + combined with '--version' it produces a display showing only the + program name and version number. + +'--compact' + Give compact output featuring only the conversion factor; the + multiplication and division signs are not shown, and there is no + leading whitespace. If you convert to a unit list, then the output + is a semicolon separated list of factors. This turns off the + '--verbose' option. + +'-q' +'--quiet' +'--silent' + Suppress the display of statistics about the number of units + loaded, any messages printed by the units database, and the + prompting of the user for units. This option does not affect how + 'units' displays the results. This option is turned on by default + if you invoke 'units' with a unit expression on the command line. + ---------- Footnotes ---------- (1) This document refers to "decimal point," but strictly, the @@ -1586,9 +1866,114 @@ in most other countries it is a comma (',').  -File: units.info, Node: Defining Your Own Units, Next: Numeric Output Format, Prev: Invoking Units, Up: Top +File: units.info, Node: Output Styles, Next: Defining Your Own Units, Prev: Invoking Units, Up: Top + +11 Output Styles +**************** -10 Adding Your Own Definitions +The output can be tweaked in various ways using command line options. +With no options, the output looks like this + + $ units + Currency exchange rates from FloatRates (USD base) on 2019-02-20 + 3070 units, 109 prefixes, 109 nonlinear units + + You have: 23ft + You want: m + * 7.0104 + / 0.14264521 + You have: m + You want: ft;in + 3 ft + 3.3700787 in + +This is arguably a bit cryptic; the '--verbose' option makes clear what +the output means: + + $ units --verbose + Currency exchange rates from FloatRates (USD base) on 2019-02-20 + 3070 units, 109 prefixes, 109 nonlinear units + + You have: 23 ft + You want: m + 23 ft = 7.0104 m + 23 ft = (1 / 0.14264521) m + You have: meter + You want: ft;in + meter = 3 ft + 3.3700787 in + +The '--quiet' option suppresses the clutter displayed when 'units' +starts, as well as the prompts to the user. This option is enabled by +default when you give units on the command line. + + $ units --quiet + 23 ft + m + * 7.0104 + / 0.14264521 + + $ units 23ft m + * 7.0104 + / 0.14264521 + +The remaining style options allow you to display only numerical values +without the tab or the multiplication and division signs, or to display +just a single line showing the forward conversion: + + $ units --compact 23ft m + 7.0104 + 0.14264521 + + $ units --compact m 'ft;in' + 3;3.3700787 + + $ units --one-line 23ft m + * 7.0104 + + $ units --one-line 23ft 1/m + reciprocal conversion + * 0.14264521 + + $ units --one-line 23ft kg + conformability error + 7.0104 m + 1 kg + +Note that when converting to a unit list, the '--compact' option +displays a semicolon separated list of results. Also be aware that the +'one-line' option doesn't live up to its name if you execute a +reciprocal conversion or if you get a conformability error. The former +case can be prevented using the '--strict' option, which suppresses +reciprocal conversions. Similarly you can suppress unit list conversion +using '--nolists'. It is impossible to prevent the three line error +output. + + $ units --compact --nolists m 'ft;in' + Error in 'ft;in': Parse error + + $ units --one-line --strict 23ft 1/m + +The various style options can be combined appropriately. The ultimate +combination is the '--terse' option, which combines '--strict', +'--quiet', '--one-line', and '--compact' to produce the minimal output, +just a single number for regular conversions and a semicolon separated +list for conversion to unit lists. This will likely be the best choice +for programs that want to call 'units' and then process its result. + + $ units --terse 23ft m + 7.0104 + + $ units --terse m 'ft;in' + 3;3.3700787 + + $ units --terse 23ft 1/m + conformability error + 7.0104 m + 1 / m + + +File: units.info, Node: Defining Your Own Units, Next: Numeric Output Format, Prev: Output Styles, Up: Top + +12 Adding Your Own Definitions ****************************** * Menu: @@ -1602,7 +1987,7 @@  File: units.info, Node: Units Data Files, Next: Defining New Units, Up: Defining Your Own Units -10.1 Units Data Files +12.1 Units Data Files ===================== The units and prefixes that 'units' can convert are defined in the units @@ -1650,7 +2035,7 @@  File: units.info, Node: Defining New Units, Next: Defining Nonlinear Units, Prev: Units Data Files, Up: Defining Your Own Units -10.2 Defining New Units and Prefixes +12.2 Defining New Units and Prefixes ==================================== A unit is specified on a single line by giving its name and an @@ -1662,7 +2047,7 @@ followed by the file's name. The '!' must be the first character on the line. The file will be sought in the same directory as the parent file unless you give a full path. The name of the file to be included cannot -contain the comment character '#'. +contain spaces or the comment character '#'. Unit names must not contain any of the operator characters '+', '-', '*', '/', '|', '^', ';', '~', the comment character '#', or parentheses. @@ -1694,16 +2079,23 @@ unit as it is checked. The program will still hang, but the last unit printed will be the unit that caused the infinite loop. - If you define any units that contain '+' characters, carefully check -them because the '-c' option will not catch non-conformable sums. Be -careful with the '-' operator as well. When used as a binary operator, -the '-' character can perform addition or multiplication depending on -the options used to invoke 'units'. To ensure consistent behavior use -'-' only as a unary negation operator when writing units definitions. -To multiply two units leave a space or use the '*' operator with care, -recalling that it has two possible precedence values and may require -parentheses to ensure consistent behavior. To compute the difference of -'foo' and 'bar' write 'foo+(-bar)' or even 'foo+-bar'. + If you define any units that contain '+' characters in their +definitions, carefully check them because the '-c' option will not catch +non-conformable sums. Be careful with the '-' operator as well. When +used as a binary operator, the '-' character can perform addition or +multiplication depending on the options used to invoke 'units'. To +ensure consistent behavior use '-' only as a unary negation operator +when writing units definitions. To multiply two units leave a space or +use the '*' operator with care, recalling that it has two possible +precedence values and may require parentheses to ensure consistent +behavior. To compute the difference of 'foo' and 'bar' write +'foo+(-bar)' or even 'foo+-bar'. + + You may wish to intentionally redefine a unit. When you do this, and +use the '-c' option, 'units' displays a warning message about the +redefinition. You can suppress these warnings by redefining a unit +using a '+' at the beginning of the unit name. Do not include any white +space between the '+' and the redefined unit name. Here is an example of a short data file that defines some basic units: @@ -1714,19 +2106,20 @@ micro- 1e-6 # Define a prefix minute 60 sec # A minute is 60 seconds hour 60 min # An hour is 60 minutes - inch 0.0254 m # Inch defined in terms of meters + inch 72 m # Inch defined incorrectly terms of meters ft 12 inches # The foot defined in terms of inches mile 5280 ft # And the mile + +inch 0.0254 m # Correct redefinition, warning suppressed A unit that ends with a '-' character is a prefix. If a prefix definition contains any '/' characters, be sure they are protected by -parentheses. If you define 'half- 1/2' then 'halfmeter' would be +parentheses. If you define 'half- 1/2', then 'halfmeter' would be equivalent to '1 / (2 meter)'.  File: units.info, Node: Defining Nonlinear Units, Next: Piecewise Linear Units, Prev: Defining New Units, Up: Defining Your Own Units -10.3 Defining Nonlinear Units +12.3 Defining Nonlinear Units ============================= Some unit conversions of interest are nonlinear; for example, @@ -1849,7 +2242,7 @@ comparison. Without units, numerical values other than zero or plus or minus infinity for domain or range endpoints are meaningless, and accordingly they are not allowed. If you give other values without -units then the definition will be ignored and you will get an error +units, then the definition will be ignored and you will get an error message. Although the units, domain, and range specifications are optional, @@ -1898,7 +2291,7 @@  File: units.info, Node: Piecewise Linear Units, Next: Defining Unit List Aliases, Prev: Defining Nonlinear Units, Up: Defining Your Own Units -10.4 Defining Piecewise Linear Units +12.4 Defining Piecewise Linear Units ==================================== Sometimes you may be interested in a piecewise linear unit such as many @@ -1989,7 +2382,7 @@  File: units.info, Node: Defining Unit List Aliases, Prev: Piecewise Linear Units, Up: Defining Your Own Units -10.5 Defining Unit List Aliases +12.5 Defining Unit List Aliases =============================== Unit list aliases are treated differently from unit definitions, because @@ -2016,7 +2409,7 @@  File: units.info, Node: Numeric Output Format, Next: Localization, Prev: Defining Your Own Units, Up: Top -11 Numeric Output Format +13 Numeric Output Format ************************ * Menu: @@ -2043,7 +2436,7 @@  File: units.info, Node: Format Specification, Next: Flags, Up: Numeric Output Format -11.1 Format Specification +13.1 Format Specification ========================= The format specification recognized with the '--output-format' option is @@ -2080,7 +2473,7 @@  File: units.info, Node: Flags, Next: Field Width, Prev: Format Specification, Up: Numeric Output Format -11.2 Flags +13.2 Flags ========== The '+' flag causes the output to have a sign ('+' or '-'). The space @@ -2131,7 +2524,7 @@  File: units.info, Node: Field Width, Next: Precision, Prev: Flags, Up: Numeric Output Format -11.3 Field Width +13.3 Field Width ================ By default, the output value is left aligned and shown with the minimum @@ -2160,7 +2553,7 @@  File: units.info, Node: Precision, Prev: Field Width, Up: Numeric Output Format -11.4 Precision +13.4 Precision ============== The meaning of "precision" depends on the format type. With 'g' or 'G', @@ -2216,7 +2609,7 @@  File: units.info, Node: Localization, Next: Environment Vars, Prev: Numeric Output Format, Up: Top -12 Localization +14 Localization *************** * Menu: @@ -2231,7 +2624,7 @@  File: units.info, Node: Locale, Next: Additional Localization, Up: Localization -12.1 Locale +14.1 Locale =========== A locale is a subset of a user's environment that indicates the user's @@ -2278,7 +2671,7 @@  File: units.info, Node: Additional Localization, Prev: Locale, Up: Localization -12.2 Additional Localization +14.2 Additional Localization ============================ Sometimes the locale isn't sufficient to determine unit preferences. @@ -2301,7 +2694,7 @@ list values. The inch has long been a customary measure of length in many places. -The word comes from the latin _uncia_ meaning "one twelfth," referring +The word comes from the Latin _uncia_ meaning "one twelfth," referring to its relationship with the foot. By the 20th century, the inch was officially defined in English-speaking countries relative to the yard, but until 1959, the yard differed slightly among those countries. In @@ -2334,7 +2727,7 @@ When 'units' reads the above definitions it will check the environment variable 'INCH_UNIT' and load only the definitions for the appropriate section. If 'INCH_UNIT' is unset or is not set to one of the four -values listed then 'units' will run the last block. In this case that +values listed, then 'units' will run the last block. In this case that block uses the '!message' command to display a warning message. Alternatively that block could set default values. @@ -2342,7 +2735,7 @@ settings the data file can use the '!set' command, which sets an environment variable _only if it is not already set_; these settings are only for the current 'units' invocation and do not persist. So if the -example above were preceded by '!set INCH_UNIT france' then this would +example above were preceded by '!set INCH_UNIT france', then this would make 'france' the default value for 'INCH_UNIT'. If the user had set the variable in the environment before invoking 'units', then 'units' would use the user's value. @@ -2371,7 +2764,7 @@ default setting comes last so that it only applies when 'INCH_UNIT' was not set by one of the other commands or by the user. - If the variable given after '!var' or '!varnot' is undefined then + If the variable given after '!var' or '!varnot' is undefined, then 'units' prints an error message and ignores the definitions that follow. Use '!set' to create defaults to prevent this situation from arising. The '-c' option only checks the definitions that are active for the @@ -2381,7 +2774,7 @@  File: units.info, Node: Environment Vars, Next: Data Files, Prev: Localization, Up: Top -13 Environment Variables +15 Environment Variables ************************ The 'units' program uses the following environment variables: @@ -2434,10 +2827,15 @@ the 'UNITSFILE' environment variable, and that location does not also contain the locale map file. +'UNITS_SYSTEM' + This environment variable is used in the standard data file to + select CGS measurement systems. Currently supported systems are + 'esu', 'emu', 'gauss[ian]', and 'si'. The default is 'si'. +  File: units.info, Node: Data Files, Next: Unicode Support, Prev: Environment Vars, Up: Top -14 Data Files +16 Data Files ************* The 'units' program uses two default data files: 'definitions.units' and @@ -2449,7 +2847,8 @@ On Unix-like systems, the data files are typically located in '/usr/share/units' if 'units' is provided with the operating system, or in '/usr/local/share/units' if 'units' is compiled from the source -distribution. +distribution. Note that the currency file 'currency.units' is a +symbolic link to another location. On systems running Microsoft Windows, the files may be in the same locations if Unix-like commands are available, a Unix-like file @@ -2477,7 +2876,7 @@  File: units.info, Node: Unicode Support, Next: Readline Support, Prev: Data Files, Up: Top -15 Unicode Support +17 Unicode Support ****************** The standard units data file is in Unicode, using UTF-8 encoding. Most @@ -2485,28 +2884,35 @@ U+007F); definitions using non-ASCII characters appear in blocks beginning with '!utf8' and ending with '!endutf8'. - When 'units' starts, it checks the locale to determine the character -set. If 'units' is compiled with Unicode support and definitions; -otherwise these definitions are ignored. When Unicode support is -active, 'units' will check every line of all of the units data files for -invalid or non-printing UTF-8 sequences; if such sequences occur, -'units' ignores the entire line. In addition to checking validity, -'units' determines the display width of non-ASCII characters to ensure -proper positioning of the pointer in some error messages and to align -columns for the 'search' and '?' commands. - - At present, 'units' does not support Unicode under Microsoft Windows. -The UTF-16 and UTF-32 encodings are not supported on any systems. - - If definitions that contain non-ASCII characters are added to a units -data file, those definitions should be enclosed within '!utf8' ... -'!endutf8' to ensure that they are only loaded when Unicode support is -available. As usual, the '!' must appear as the first character on the -line. As discussed in *note Units Data Files::, it's usually best to -put such definitions in supplemental data files linked by an '!include' -command or in a personal units data file. + The non-ASCII definitions are loaded only if the platform and the +locale support UTF-8. Platform support is determined when 'units' is +compiled; the locale is checked at every invocation of 'units'. To see +if your version of 'units' includes Unicode support, invoke the program +with the '--version' option. + + When Unicode support is available, 'units' checks every line within +UTF-8 blocks in all of the units data files for invalid or non-printing +UTF-8 sequences; if such sequences occur, 'units' ignores the entire +line. In addition to checking validity, 'units' determines the display +width of non-ASCII characters to ensure proper positioning of the +pointer in some error messages and to align columns for the 'search' and +'?' commands. + + As of early 2019, Microsoft Windows provides limited support for +UTF-8 in console applications, and accordingly, 'units' does not support +Unicode on Windows. The UTF-16 and UTF-32 encodings are not supported +on any platforms. + + If Unicode support is available and definitions that contain +non-ASCII UTF-8 characters are added to a units data file, those +definitions should be enclosed within '!utf8' ... '!endutf8' to ensure +that they are only loaded when Unicode support is available. As usual, +the '!' must appear as the first character on the line. As discussed in +*note Units Data Files::, it's usually best to put such definitions in +supplemental data files linked by an '!include' command or in a personal +units data file. - When Unicode support is not active, 'units' makes no assumptions + When Unicode support is not available, 'units' makes no assumptions about character encoding, except that characters in the range 00-7F hexadecimal correspond to ASCII encoding. Non-ASCII characters are simply sequences of bytes, and have no special meanings; for definitions @@ -2514,11 +2920,13 @@ with this assumption. For example, if you wish to use non-ASCII characters in definitions when running 'units' under Windows, you can use a character set such as Windows "ANSI" (code page 1252 in the US and -Western Europe). You can even use UTF-8, though some messages may be -improperly aligned, and 'units' will not detect invalid UTF-8 sequences. -If you use UTF-8 encoding when Unicode support is not active, you should -place any definitions with non-ASCII characters _outside_ '!utf8' ... -'!endutf8' blocks--otherwise, they will be ignored. +Western Europe); if this is done, the console code page must be set to +the same encoding for the characters to display properly. You can even +use UTF-8, though some messages may be improperly aligned, and 'units' +will not detect invalid UTF-8 sequences. If you use UTF-8 encoding when +Unicode support is not available, you should place any definitions with +non-ASCII characters _outside_ '!utf8' ... '!endutf8' blocks--otherwise, +they will be ignored. Typeset material other than code examples usually uses the Unicode minus (U+2212) rather than the ASCII hyphen-minus operator (U+002D) used @@ -2531,7 +2939,7 @@  File: units.info, Node: Readline Support, Next: Currency, Prev: Unicode Support, Up: Top -16 Readline Support +18 Readline Support ******************* If the 'readline' package has been compiled in, then when 'units' is @@ -2544,7 +2952,7 @@ allow editing in the style of emacs. Of particular use with 'units' are the completion commands. - If you type a few characters and then hit followed by '?' then + If you type a few characters and then hit followed by '?', then 'units' will display a list of all the units that start with the characters typed. For example, if you type 'metr' and then request completion, you will see something like this: @@ -2555,7 +2963,7 @@ metriccarat metricgrain metricquart metricyarncount You have: metr -If there is a unique way to complete a unitname, you can hit the +If there is a unique way to complete a unit name, you can hit the key and 'units' will provide the rest of the unit name. If 'units' beeps, it means that there is no unique completion. Pressing the key a second time will print the list of all completions. @@ -2575,29 +2983,109 @@  File: units.info, Node: Currency, Next: Database Syntax, Prev: Readline Support, Up: Top -17 Updating Currency Exchange Rates +19 Updating Currency Exchange Rates *********************************** -The units program includes currency exchange rates and prices for some -precious metals in the database. Of course, these values change over -time, sometimes very rapidly, and 'units' cannot provide real time -values. To update the exchange rates run the 'units_cur', which -rewrites the files containing the currency rates, typically -'/usr/share/units/currency.units'. This program requires 'python', and -must be run with suitable permissions to write the file. To keep the -rates updated automatically, run it using a cron job on a Unix-like -system, or a similar scheduling program on a different system. Currency -exchange rates are taken from Yahoo () and -precious metals pricing from Packetizer (). These -sites update once per day, so there is no benefit in running the update -script more often than daily. You can run 'units_cur' with a filename -specified on the command line and it will write the data to that file. +The units program database includes currency exchange rates and prices +for some precious metals. Of course, these values change over time, +sometimes very rapidly, and 'units' cannot provide real-time values. To +update the exchange rates, run 'units_cur', which rewrites the file +containing the currency rates, typically '/var/lib/units/currency.units' +or '/usr/local/com/units/currency.units' on a Unix-like system or +'C:\Program Files (x86)\GNU\units\definitions.units' on a Windows +system. + + This program requires Python (); either +version 2 or 3 will work. The program must be run with suitable +permissions to write the file. To keep the rates updated automatically, +run it using a cron job on a Unix-like system, or a similar scheduling +program on a different system. + + Reliable free sources of currency exchange rates have been annoyingly +ephemeral. The program currently supports several sources: + + * FloatRates (). The US dollar ('USD') + is the default base currency. You can change the base currency + with the '-b' option described below. Allowable base currencies + are listed on the FloatRates website. Exchange rates update daily. + + * The European Central Bank (). The base + currency is always the euro ('EUR'). Exchange rates update daily. + This source offers a more limited list of currencies than the + others. + + * Fixer (). Registration for a free API key is + required. With a free API key, base currency is the euro; exchange + rates are updated hourly, the service has a limit of 1,000 API + calls per month, and SSL encryption (https protocol) is not + available. Most of these restrictions are eliminated or reduced + with paid plans. + + * open exchange rates (). + Registration for a free API key is required. With a free API key, + the base currency is the US dollar; exchange rates are updated + hourly, and there is a limit of 1,000 API calls per month. Most of + these restrictions are eliminated or reduced with paid plans. + +The default source is FloatRates; you can select a different one using +'-s' option described below. + + Precious metals pricing is obtained from Packetizer +(). This site updates once per day. + + You invoke 'units_cur' like this: + + units_cur [OPTIONS] [OUTFILE] + +By default, the output is written to the default currency file described +above; this is usually what you want, because this is where 'units' +looks for the file. If you wish, you can specify a different filename +on the command line and 'units_cur' will write the data to that file. If you give '-' for the file it will write to standard output. +The following options are available: + +'-h' +'--help' + Print a summary of the options for 'units_cur'. + +'-V' +'--version' + Print the 'units_cur' version number. + +'-v' +'--verbose' + Give slightly more verbose output when attempting to update + currency exchange rates. + +'-s SOURCE' +'--source SOURCE' + Specify the source for currency exchange rates; currently supported + values are 'floatrates' (for FloatRates), 'eubank' (for the + European Central Bank), 'fixer' (for Fixer), and + 'openexchangerates' (for open exchange rates); the last two require + an API key to be given with the '-k' option. + +'-b BASE' +'--base BASE' + Set the base currency (when allowed by the site providing the + data). BASE should be a 3-letter ISO currency code, e.g., 'USD'. + The specified currency will be the primitive currency unit used by + 'units'. You may find it convenient to specify your local + currency. Conversions may be more accurate and you will be able to + convert to your currency by simply hitting at the + 'You want:' prompt. This option is ignored if the source does not + allow specifying the base currency. (Currently only floatrates + supports this option.) + +'-k KEY' +'--key KEY' + Set the API key to KEY for sources that require it. +  File: units.info, Node: Database Syntax, Next: GNU Free Documentation License, Prev: Currency, Up: Top -18 Database Command Syntax +20 Database Command Syntax ************************** UNIT DEFINITION @@ -2633,7 +3121,12 @@ !message TEXT Display TEXT when the database is read unless the quiet option - ('-q') is enabled. + ('-q') is enabled. If you omit TEXT, then units will display a + blank line. Messages will also appear in the log file. + +!prompt TEXT + Prefix the 'You have:' prompt with the specified text. If you omit + TEXT, then any existing prefix is canceled. !set VARIABLE VALUE Sets the environment variable, VARIABLE, to the specified value @@ -2661,7 +3154,7 @@  File: units.info, Node: GNU Free Documentation License, Next: Index, Prev: Database Syntax, Up: Top -19 GNU Free Documentation License +21 GNU Free Documentation License ********************************* Version 1.3, 3 November 2008 @@ -3165,52 +3658,54 @@ (line 17) * - as subtraction operator: Sums and Differences of Units. (line 6) -* --check (option for units): Invoking Units. (line 50) -* --check-verbose (option for units): Invoking Units. (line 59) -* --compact (option for units): Invoking Units. (line 170) -* --digits (option for units): Invoking Units. (line 67) -* --exponential (option for units): Invoking Units. (line 84) -* --file (option for units): Invoking Units. (line 115) -* --file (option for units) <1>: Invoking Units. (line 137) -* --help (option for units): Invoking Units. (line 146) -* --info (option for units): Invoking Units. (line 256) -* --locale (option for units): Invoking Units. (line 275) -* --log (option for units): Invoking Units. (line 127) -* --minus (option for units): Invoking Units. (line 150) -* --newstar (option for units): Invoking Units. (line 165) -* --oldstar (option for units): Invoking Units. (line 161) -* --one-line (option for units): Invoking Units. (line 218) -* --output-format (option for units): Invoking Units. (line 93) -* --product (option for units): Invoking Units. (line 155) -* --quiet (option for units): Invoking Units. (line 176) -* --silent (option for units): Invoking Units. (line 176) -* --strict (option for units): Invoking Units. (line 209) -* --terse (option for units): Invoking Units. (line 225) -* --unitsfile (option for units): Invoking Units. (line 270) -* --verbose (option for units): Invoking Units. (line 234) -* --verbose-check (option for units): Invoking Units. (line 59) -* --version (option for units): Invoking Units. (line 241) -* -1 (option for units): Invoking Units. (line 218) -* -c (option for units): Invoking Units. (line 50) -* -d (option for units): Invoking Units. (line 67) -* -e (option for units): Invoking Units. (line 84) -* -f (option for units): Invoking Units. (line 115) -* -f (option for units) <1>: Invoking Units. (line 137) -* -h (option for units): Invoking Units. (line 146) -* -I (option for units): Invoking Units. (line 256) -* -L (option for units): Invoking Units. (line 127) -* -l (option for units): Invoking Units. (line 275) -* -m (option for units): Invoking Units. (line 150) -* -o (option for units): Invoking Units. (line 93) -* -p (option for units): Invoking Units. (line 155) -* -q (option for units): Invoking Units. (line 176) -* -s (option for units): Invoking Units. (line 209) -* -t (option for units): Invoking Units. (line 225) -* -U (option for units): Invoking Units. (line 270) -* -v (option for units): Invoking Units. (line 234) -* -V (option for units): Invoking Units. (line 241) +* --check (option for units): Invoking Units. (line 52) +* --check-verbose (option for units): Invoking Units. (line 61) +* --compact (option for units): Invoking Units. (line 276) +* --digits (option for units): Invoking Units. (line 69) +* --exponential (option for units): Invoking Units. (line 86) +* --file (option for units): Invoking Units. (line 117) +* --file (option for units) <1>: Invoking Units. (line 139) +* --help (option for units): Invoking Units. (line 148) +* --info (option for units): Invoking Units. (line 219) +* --locale (option for units): Invoking Units. (line 242) +* --log (option for units): Invoking Units. (line 129) +* --minus (option for units): Invoking Units. (line 152) +* --newstar (option for units): Invoking Units. (line 167) +* --oldstar (option for units): Invoking Units. (line 163) +* --one-line (option for units): Invoking Units. (line 262) +* --output-format (option for units): Invoking Units. (line 95) +* --product (option for units): Invoking Units. (line 157) +* --quiet (option for units): Invoking Units. (line 285) +* --silent (option for units): Invoking Units. (line 285) +* --strict (option for units): Invoking Units. (line 253) +* --terse (option for units): Invoking Units. (line 268) +* --units (option for units): Invoking Units. (line 238) +* --unitsfile (option for units): Invoking Units. (line 233) +* --verbose (option for units): Invoking Units. (line 197) +* --verbose-check (option for units): Invoking Units. (line 61) +* --version (option for units): Invoking Units. (line 204) +* -1 (option for units): Invoking Units. (line 262) +* -c (option for units): Invoking Units. (line 52) +* -d (option for units): Invoking Units. (line 69) +* -e (option for units): Invoking Units. (line 86) +* -f (option for units): Invoking Units. (line 117) +* -f (option for units) <1>: Invoking Units. (line 139) +* -h (option for units): Invoking Units. (line 148) +* -I (option for units): Invoking Units. (line 219) +* -L (option for units): Invoking Units. (line 129) +* -l (option for units): Invoking Units. (line 242) +* -m (option for units): Invoking Units. (line 152) +* -o (option for units): Invoking Units. (line 95) +* -p (option for units): Invoking Units. (line 157) +* -q (option for units): Invoking Units. (line 285) +* -s (option for units): Invoking Units. (line 253) +* -t (option for units): Invoking Units. (line 268) +* -U (option for units): Invoking Units. (line 233) +* -u (option for units): Invoking Units. (line 238) +* -v (option for units): Invoking Units. (line 197) +* -V (option for units): Invoking Units. (line 204) * ? for unit completion with readline: Readline Support. (line 16) -* ? to show conformable units: Interactive Use. (line 131) +* ? to show conformable units: Interactive Use. (line 130) * _ to use result of previous conversion: Previous Result. (line 6) * | operator: Operators. (line 51) * abrasive grit size: Other Nonlinear Units. @@ -3221,6 +3716,12 @@ * backwards compatibility: Backwards Compatibility. (line 6) * British Imperial measure: Unit Definitions. (line 37) +* built-in functions: Built-in Functions. (line 6) +* CGS Units Systems: CGS Units Systems. (line 6) +* CGS units, prompt prefix: Prompt Prefix. (line 6) +* CGS units, specifying: Specifying CGS Units. + (line 6) +* CGS units, using: Using CGS Units. (line 6) * circle, area of: Other Nonlinear Units. (line 42) * command, ! to indicate primitive units: Defining New Units. (line 6) @@ -3245,7 +3746,7 @@ (line 6) * completion, unit, using ? (readline only): Readline Support. (line 16) -* conformable units, ? to show: Interactive Use. (line 131) +* conformable units, ? to show: Interactive Use. (line 130) * currency, updating: Currency. (line 6) * Darcy-Weisbach equation: Complicated Unit Expressions. (line 7) @@ -3264,7 +3765,7 @@ (line 33) * differences of units: Sums and Differences of Units. (line 9) -* dimensionless units: Interactive Use. (line 129) +* dimensionless units: Interactive Use. (line 128) * dimensionless units, defining: Defining New Units. (line 38) * division of numbers: Operators. (line 51) * division of units: Operators. (line 14) @@ -3280,6 +3781,7 @@ * environment variable, UNITSFILE: Environment Vars. (line 42) * environment variable, UNITSLOCALEMAP: Environment Vars. (line 49) * environment variable, UNITS_ENGLISH: Environment Vars. (line 38) +* environment variable, UNITS_SYSTEM: Environment Vars. (line 58) * environment variables: Environment Vars. (line 6) * exchange rates, updating: Currency. (line 6) * exponent operator: Operators. (line 70) @@ -3291,7 +3793,7 @@ * functions of units: Defining Nonlinear Units. (line 162) * functions, built in: Built-in Functions. (line 6) -* help: Interactive Use. (line 137) +* help: Interactive Use. (line 136) * help <1>: Environment Vars. (line 31) * HOME environment variable: Environment Vars. (line 9) * hyphen as multiplication operator: Backwards Compatibility. @@ -3299,7 +3801,7 @@ * Imperial measure: Unit Definitions. (line 37) * include files: Defining New Units. (line 15) * including additional units data files: Units Data Files. (line 6) -* incompatible units: Interactive Use. (line 87) +* incompatible units: Interactive Use. (line 86) * interactive use: Interactive Use. (line 6) * international mile: Unit Definitions. (line 77) * international yard: Unit Definitions. (line 77) @@ -3317,6 +3819,7 @@ (line 6) * logging calculations: Logging Calculations. (line 6) +* logs: Built-in Functions. (line 27) * measure, Imperial: Unit Definitions. (line 37) * mile, international: Unit Definitions. (line 77) * minus (-) operator, subtraction: Sums and Differences of Units. @@ -3326,7 +3829,7 @@ (line 17) * MYUNITSFILE environment variable: Units Data Files. (line 43) * MYUNITSFILE environment variable <1>: Environment Vars. (line 25) -* non-conformable units: Interactive Use. (line 87) +* non-conformable units: Interactive Use. (line 86) * non-interactive unit conversion: Command Line Use. (line 6) * nonlinear unit conversions: Nonlinear Conversions. (line 6) @@ -3374,7 +3877,7 @@ * parentheses <4>: Complicated Unit Expressions. (line 27) * parentheses <5>: Defining New Units. (line 47) -* parentheses <6>: Defining New Units. (line 71) +* parentheses <6>: Defining New Units. (line 79) * parentheses <7>: Defining Nonlinear Units. (line 36) * per operator: Operators. (line 14) @@ -3391,21 +3894,22 @@ * previous result: Previous Result. (line 6) * primitive units: Defining New Units. (line 6) * products of units: Operators. (line 14) +* prompt prefix with CGS units: Prompt Prefix. (line 6) * quotients of units: Operators. (line 14) * range, nonlinear unit definitions: Defining Nonlinear Units. (line 90) * readline, use with units: Readline Support. (line 6) -* reciprocal conversion: Interactive Use. (line 62) -* roots: Built-in Functions. (line 27) +* reciprocal conversion: Interactive Use. (line 61) +* roots: Built-in Functions. (line 51) * setlocale function: Locale. (line 17) * slash (/) operator: Operators. (line 14) * solidus (/) operator: Operators. (line 14) * sphere, volume of: Other Nonlinear Units. (line 42) -* square roots: Built-in Functions. (line 27) +* square roots: Built-in Functions. (line 51) * star (*) operator: Operators. (line 14) * State Plane Coordinate System, US: Unit Definitions. (line 77) -* strict conversion: Interactive Use. (line 71) +* strict conversion: Interactive Use. (line 70) * subtraction of units: Sums and Differences of Units. (line 9) * sums and differences of units: Sums and Differences of Units. @@ -3436,6 +3940,7 @@ * units functions: Defining Nonlinear Units. (line 162) * units quotients: Operators. (line 14) +* units systems, CGS: CGS Units Systems. (line 6) * units, definition of: Defining New Units. (line 6) * units, lookup method: Unit Definitions. (line 47) * units, piecewise linear: Piecewise Linear Units. @@ -3447,13 +3952,14 @@ * UNITSFILE environment variable: Environment Vars. (line 42) * UNITSLOCALEMAP environment variable: Environment Vars. (line 49) * UNITS_ENGLISH environment variable: Environment Vars. (line 38) +* UNITS_SYSTEM environment variable: Environment Vars. (line 58) * US State Plane Coordinate System: Unit Definitions. (line 77) * US survey foot: Unit Definitions. (line 77) * US survey measure: Unit Definitions. (line 77) * US survey mile: Unit Definitions. (line 77) * UTF-8: Unicode Support. (line 6) -* verbose output: Interactive Use. (line 53) -* verbose output <1>: Interactive Use. (line 71) +* verbose output: Interactive Use. (line 52) +* verbose output <1>: Interactive Use. (line 70) * vertical bar (|) operator: Operators. (line 51) * volume measure, English customary: Unit Definitions. (line 62) * white space: Operators. (line 36) @@ -3465,48 +3971,54 @@  Tag Table: -Node: Top845 -Node: Overview2327 -Ref: Overview-Footnote-14091 -Node: Interactive Use4285 -Node: Command Line Use10181 -Node: Unit Definitions11427 -Node: Unit Expressions17637 -Node: Operators18250 -Node: Sums and Differences of Units23617 -Node: Numbers as Units25659 -Node: Built-in Functions26464 -Node: Previous Result27747 -Node: Complicated Unit Expressions30073 -Node: Backwards Compatibility31708 -Node: Nonlinear Conversions33609 -Node: Temperature Conversions34048 -Node: Other Nonlinear Units36113 -Node: Unit Lists39250 -Node: Logging Calculations48022 -Node: Invoking Units50682 -Ref: Invoking Units-Footnote-163408 -Node: Defining Your Own Units63662 -Node: Units Data Files64200 -Node: Defining New Units66688 -Node: Defining Nonlinear Units70591 -Node: Piecewise Linear Units78768 -Node: Defining Unit List Aliases82525 -Node: Numeric Output Format83685 -Node: Format Specification84958 -Node: Flags86920 -Node: Field Width89003 -Node: Precision90038 -Node: Localization92495 -Node: Locale92938 -Node: Additional Localization94951 -Node: Environment Vars99404 -Node: Data Files101963 -Node: Unicode Support103750 -Node: Readline Support106710 -Node: Currency108854 -Node: Database Syntax110057 -Node: GNU Free Documentation License112120 -Node: Index137252 +Node: Top842 +Node: Overview2454 +Ref: Overview-Footnote-14218 +Node: Interactive Use4412 +Node: Command Line Use10215 +Node: Unit Definitions11648 +Node: Unit Expressions17859 +Node: Operators18472 +Node: Sums and Differences of Units23839 +Node: Numbers as Units25881 +Node: Built-in Functions26686 +Node: Previous Result28702 +Node: Complicated Unit Expressions31028 +Node: Backwards Compatibility32661 +Node: Nonlinear Conversions34563 +Node: Temperature Conversions35002 +Node: Other Nonlinear Units37067 +Node: Unit Lists40204 +Node: Using CGS Units48971 +Node: Specifying CGS Units51629 +Node: CGS Units Systems53633 +Node: Conversions Between Systems55207 +Node: Prompt Prefix58901 +Node: Logging Calculations59785 +Node: Invoking Units62450 +Ref: Invoking Units-Footnote-175733 +Node: Output Styles75987 +Node: Defining Your Own Units79066 +Node: Units Data Files79603 +Node: Defining New Units82091 +Node: Defining Nonlinear Units86440 +Node: Piecewise Linear Units94618 +Node: Defining Unit List Aliases98375 +Node: Numeric Output Format99535 +Node: Format Specification100808 +Node: Flags102770 +Node: Field Width104853 +Node: Precision105888 +Node: Localization108345 +Node: Locale108788 +Node: Additional Localization110801 +Node: Environment Vars115257 +Node: Data Files118035 +Node: Unicode Support119908 +Node: Readline Support123271 +Node: Currency125417 +Node: Database Syntax129684 +Node: GNU Free Documentation License131989 +Node: Index157121  End Tag Table diff -Nru units-2.16/units.man units-2.19/units.man --- units-2.16/units.man 2017-11-01 02:16:28.000000000 +0000 +++ units-2.19/units.man 2019-05-29 00:32:20.000000000 +0000 @@ -1,65 +1,169 @@ .\"Do not edit this file. It was created from units.texinfo -.\"using texi2man version 1.01s on Tue Oct 31 22:16:28 EDT 2017 -.\"This manual is for GNU Units (version 2.16), +.\"using texi2man version 1.01w on Tue 28 May 2019 08:32:20 PM EDT +.\"This manual is for GNU Units (version 2.18), .\"which performs units conversions and units calculations. .\" .\"Copyright \(co 1996, 1997, 1999, 2000, 2001, 2002, 2004, 2005, 2007, -.\"2011\-2017 Free Software Foundation, Inc. +.\"2011\-2019 Free Software Foundation, Inc. .\" .\"Permission is granted to copy, distribute and/or modify this document .\"under the terms of the GNU Free Documentation License, Version 1.3 or .\"any later version published by the Free Software Foundation; with no .\"Invariant Sections, with no Front-Cover Texts, and with no Back-Cover .\"Texts. -.TH UNITS 1 "16 October 2017" +.TH UNITS 1 "19 March 2019" .\" -.\" ensure that ASCII circumflex U+005E (^) is not remapped with groff -.if \n(.g .tr ^\(ha +.if \n(.g \{\ +. \" ensure that ASCII circumflex U+005E (^) is not remapped +. tr ^\(ha +. \" override translation in troffrc +. ie '\*[.T]'utf8' .tr `\(oq'\(cq +. \" override mapping of ` to 60h with Tascii; assume +. \" we don't need a backquote for an example +. el .if n .tr `' +.\} .\" ellipsis: space periods with troff but not with nroff .if n .ds El \&... .if t .ds El \&.\ .\ . +.if n \{\ +. tr \(bu* +. \" override translation to MIDDLE DOT +. if \n(.g .if '\*(.T'utf8' .tr \(bu\(bu +. if \n(.g .if '\*(.T'cp1252' .tr \(bu\(bu +. if \n(.g .if '\*(.T'ansi' .tr \(bu\(bu +.\} .\" .\" Extensions to man macros .\" +.\" set handling of single quotes: 0=>straight, >0=>left and right +.nr tQ 0 +.\" groff only +.if '\*(.T'utf8' .nr tQ 1 +.\" non-standard devices: Windows code page 1252 +.if '\*(.T'cp1252' .nr tQ 1 +.if '\*(.T'ansi' .nr tQ 1 .\" Constant-width font .de CW .hy 0 +.\" nroff can't show CW font, so enclose in single quotes .if n \{\ -.ie \\n(.$>2 \&\\$1'\\$2'\\$3 -.el \&'\\$1'\\$2 +. ie \\n(.g \{\ +. \" use proper opening and closing single quotes +. ie \\n(tQ>0 \{\ +. ie \\n(.$>2 \&\\$1\(oq\\$2\(cq\\$3 +. el \&\(oq\\$1\(cq\\$2 +. \} +. \" ensure neutral single quotes with Tascii +. el \{\ +. ie \\n(.$>2 \&\\$1\(aq\\$2\(aq\\$3 +. el \&\(aq\\$1\(aq\\$2 +. \} +. \} +. \" legacy nroff doesn't have 'aq', so use ' and hope for the best +. el \{\ +. ie \\n(.$>2 \&\\$1'\\$2'\\$3 +. el \&'\\$1'\\$2 +. \} .\} +.\" troff can change fonts, so no need for quotes .if t \{\ -.ie \\n(.$>2 \&\\$1\f(CW\\$2\fR\\$3 -.el \&\f(CW\\$1\fR\\$2 +. ie \\n(.$>2 \&\\$1\f(CW\\$2\fR\\$3 +. el \&\f(CW\\$1\fR\\$2 .\} .hy 14 .. .\" Constant-width oblique font .de CI .hy 0 +.\" nroff can't show CW font, so enclose in single quotes .if n \{\ -.ie \\n(.$>2 \&\\$1'\fI\\$2\fR'\\$3 -.el \&'\fI\\$1\fR'\\$2 +. ie \\n(.g \{\ +. \" use proper opening and closing single quotes +. ie \\n(tQ \{\ +. ie \\n(.$>2 \&\\$1\(oq\fI\\$2\fR\(cq\\$3 +. el \&\(oq\fI\\$1\fR\(cq\\$2 +. \} +. \" ensure neutral single quotes with Tascii +. el \{\ +. ie \\n(.$>2 \&\\$1\(aq\fI\\$2\fR\(aq\\$3 +. el \&\(aq\fI\\$1\fR\(aq\\$2 +. \} +. \} +. \" legacy nroff doesn't have 'aq', so use ' and hope for the best +. el \{ +. ie \\n(.$>2 \&\\$1'\fI\\$2\fR'\\$3 +. el \&'\fI\\$1\fR'\\$2 +. \} .\} +.\" troff can change fonts, so no need for quotes .if t \{\ -.ie \\n(.$>2 \&\\$1\f(CI\\$2\fR\\$3 -.el \&\f(CI\\$1\fR\\$2 +. ie \\n(.$>2 \&\\$1\f(CI\\$2\fR\\$3 +. el \&\f(CI\\$1\fR\\$2 .\} .hy 14 .. -.\" Constant-width font with quotes +.\" Constant-width font with quotes with nroff and troff .de CQ .hy 0 .if n \{\ -.ie \\n(.$>2 \&\\$1'\\$2'\\$3 -.el \&'\\$1'\\$2 +. ie \\n(.g \{\ +. \" use proper opening and closing single quotes +. ie \\n(tQ \{\ +. ie \\n(.$>2 \&\\$1\(oq\\$2\(cq\\$3 +. el \&\(oq\\$1\(cq\\$2 +. \} +. \" ensure neutral single quotes with Tascii +. el \{\ +. ie \\n(.$>2 \&\\$1\(aq\\$2\(aq\\$3 +. el \&\(aq\\$1\(aq\\$2 +. \} +. \} +. \" legacy nroff doesn't have 'aq', so use ' and hope for the best +. el \{\ +. ie \\n(.$>2 \&\\$1'\\$2'\\$3 +. el \&'\\$1'\\$2 +. \} .\} .if t \{\ -.ie \\n(.$>2 \&\\$1`\f(CW\\$2\fR'\\$3 -.el \&`\f(CW\\$1\fR'\\$2 +. ie \\n(.g \{\ +. ie \\n(.$>2 \&\\$1\(oq\f(CW\\$2\fR\(cq\\$3 +. el \&\(oq\f(CW\\$1\fR\(cq\\$2 +. \} +. \" legacy troff doesn't have 'oq' or 'cq' +. el \{\ +. ie \\n(.$>2 \&\\$1`\f(CW\\$2\fR'\\$3 +. el \&`\f(CW\\$1\fR'\\$2 +. \} .\} .hy 14 .. +.\" equivalent of @set codequoteundirected +.de aQ +.if \\n(.g .tr '\(aq +.. +.\" equivalent of @clear codequoteundirected +.de aE +.if \\n(.g \{ .ie \\n(tQ>0 .tr '\(cq +.el .tr '' \} +.. +.\" opening and closing double quotes +.\" groff: true opening and closing quotes +.ie \n(.g \{\ +. ds lQ \(lq +. ds rQ \(rq +.\} +.el \{\ +.\" legacy nroff: ASCII neutral double quotes +. ie n \{\ +. ds lQ "" +. ds rQ "" +. \} +.\" legacy troff: adjacent opening and closing single quotes +. el \{\ +. ds lQ `` +. ds rQ '' +. \} +.\} .\" Display start .de DS .hy 0 @@ -96,6 +200,9 @@ .. .SH NAME units \(em unit conversion and calculation program +.\" hack to prevent very thick fraction bars with gropdf +.\" '-1' makes thickness proportional to type size +.if \n(.g .if t \Z@\D't -1'@ .PP .SH SYNOPSIS .PP @@ -145,10 +252,12 @@ description of the available options. .PP .SH INTERACTING WITH \f(BIUNITS\fP -To invoke units for interactive use, type +To invoke +.CW "units" +for interactive use, type .CI "units" -at your shell -prompt. The program will print something like this: +at your +shell prompt. The program will print something like this: .PP .ES Currency exchange rates from www.timegenie.com on 2014-03-05 @@ -172,13 +281,15 @@ .CI "feet" . If the .CW "readline" -library was compiled in then \fItab\fP will +library was compiled in, then \fItab\fP will complete unit names. See \fIReadline Support\fP for more information about .CW "readline" . -To quit the program under Unix, press -\fICtrl-C\fP or \fICtrl-D\fP. Under Windows, press \fICtrl-C\fP or -\fICtrl-Z\fP; with the latter, you may also need to press \fIEnter\fP. +To quit the program type +.CI "quit" +or +.CI "exit" +at either prompt. .PP The result will be displayed in two ways. The first line of output, which is marked with a @@ -389,18 +500,28 @@ The output tells you that 2 liters is about 2.1 quarts, or alternatively that a quart is about 0.47 times 2 liters. .PP +.CW "units" +does not require a space between a numerical value and +the unit, so the previous example can be given as +.PP +.ES +units 2liters quarts +.EE +.PP +to avoid having to quote the first argument. +.PP If the conversion is successful, then .CW "units" will return success (zero) to the calling environment. If you enter non-conformable -units then +units, then .CW "units" will print a message giving the reduced form of each unit and it will return failure (nonzero) to the calling environment. .PP When you invoke .CW "units" -with only one argument, it will print out +with only one argument, it will print the definition of the specified unit. It will return failure if the unit is not defined and success if the unit is defined. .PP @@ -528,7 +649,7 @@ .CQ "en_US" locale you will get the US volume measures. In other locales the default values are the US -definitions. If you wish to force different definitions then set the +definitions. If you wish to force different definitions, then set the environment variable .CW "UNITS_ENGLISH" to either @@ -982,19 +1103,24 @@ .CQ "tan" , .CQ "ln" , .CQ "log" , -.CQ "log2" , .CQ "exp" , .CQ "acos" , -.CQ "atan" +.CQ "atan" , +.CQ "asin" , +.CQ "cosh" , +.CQ "sinh" , +.CQ "tanh" , +.CQ "acosh" , +.CQ "asinh" , and -.CQ "asin" . +.CQ "atanh" . The .CQ "sin" , .CQ "cos" , and .CQ "tan" functions require either a dimensionless argument or an argument with -dimensions of angle. +dimensions of angle. .PP .ES You have: sin(30 degrees) @@ -1014,6 +1140,42 @@ inverse trigonometric functions return arguments with dimensions of angle. .PP +The +.CQ "ln" +and +.CQ "log" +functions give natural log and log base +10 respectively. To obtain logs for any integer base, enter the +desired base immediately after +.CQ "log" . +For example, to get log +base 2 you would write +.CQ "log2" +and to get log base 47 you could +write +.CQ "log47" . +.PP +.ES +You have: log2(32) +You want: + Definition: 5 +You have: log3(32) +You want: + Definition: 3.1546488 +You have: log4(32) +You want: + Definition: 2.5 +You have: log32(32) +You want: + Definition: 1 +You have: log(32) +You want: + Definition: 1.50515 +You have: log10(32) +You want: + Definition: 1.50515 +.EE +.PP If you wish to take roots of units, you may use the .CQ "sqrt" or @@ -1115,14 +1277,14 @@ .CQ "_" before a conversion has been performed (e.g., immediately after invocation) generates an error: +.aQ .PP -.if \n(.g .tr '\(aq .ES You have: _ ^ No previous result; '_' not set .EE -.if \n(.g .tr '' +.aE .PP Accordingly, .CQ "_" @@ -1167,17 +1329,17 @@ For example, one form of the Darcy-Weisbach fluid-flow equation is .RS 5n .PP -Delta \fIP\fP = (8 / pi)^2 (rho \fIfLQ\fP^2) / \fId\fP^5, +Delta \fIP\fP = (8 / pi)^2 (\fIrho\fP \fIfLQ\fP^2) / \fId\fP^5, .RE .PP -where Delta \fIP\fP is the pressure drop, rho is the mass density, +where Delta \fIP\fP is the pressure drop, \fIrho\fP is the mass density, \fIf\fP is the (dimensionless) friction factor, \fIL\fP is the length of the pipe, \fIQ\fP is the volumetric flow rate, and \fId\fP is the pipe diameter. It might be desired to have the equation in the form .RS 5n .PP -Delta \fIP\fP = A1 rho \fIfLQ\fP^2 / \fId\fP^5 +Delta \fIP\fP = A1 \fIrho\fP \fIfLQ\fP^2 / \fId\fP^5 .RE .PP .++ @@ -1316,7 +1478,7 @@ appears after .CQ "(" or after -.CQ "+" +.CQ "+" , then it will act as a negation operator. So you can always compute 20 degrees minus 12 minutes by entering .CQ "20\ degrees + -12\ arcmin" . @@ -1455,7 +1617,7 @@ .EE .PP The last example shows the conversion from P graded sand paper, -which is the European standard and may be marked ``P600'' on the back, +which is the European standard and may be marked \*(lQP600\*(rQ on the back, to the USA standard. .PP You can compute the area of a circle using the nonlinear unit, @@ -1761,8 +1923,8 @@ This result might be fine for a baker who has a 1\ 1/2-cup measure (and recognizes the equivalence), but it may not be as useful to someone with more limited set of measures, who does want to do -additional calculations, and only wants to know ``How many 1/2-cup -measures to I need to add?'' After all, that's what was actually +additional calculations, and only wants to know \*(lQHow many 1/2-cup +measures to I need to add?\*(rQ After all, that's what was actually asked. With the .CQ "--show-factor" option, the factor will not be @@ -1881,6 +2043,354 @@ 4;0;0;3.6280454 .EE .PP +.SH USING CGS UNITS +The SI\(eman extension of the MKS (meter\-kilogram\-second) system\(emhas +largely supplanted the older CGS (centimeter\-gram\-second) system, but +CGS units are still used in a few specialized fields, especially in +physics where they lead to a more elegant formulation of Maxwell's equations. +Conversions between SI and CGS involving mechanical units are +straightforward, involving powers of 10 (e.g., 1\ m\ =\ 100\ cm). +Conversions involving electromagnetic units are more complicated, and +.CW "units" +supports three different systems of CGS units: +electrostatic units (ESU), electromagnetic units (EMU), and the +Gaussian system. +The differences between these systems +arise from different choices made for proportionality +constants in electromagnetic equations. +Coulomb's law gives electrostatic force between two +charges separated by a distance +.EQ +delim $$ +.EN +.if n \fIr\fP: +.if t $r$: +.RS 5n +.PP +.if n \fIF\fP = \fIk\fP_C \fIq\fP_1\ \fIq\fP_2\ /\ \fIr\fP^2. +.if t \{ +.EQ +F = k sub roman C { q sub 1 q sub 2} over r sup 2. +.EN +.\} +.RE +.PP +.PP +Ampere's law gives the electromagnetic force per unit length +between two current-carrying conductors separated by a distance +.if n \fIr\fP: +.if t $r$: +.RS 5n +.PP +.if n \fIF\fP/\fIl\fP = 2 \fIk\fP_A \fII\fP_1\ \fII\fP_2\ /\ \fIr\fP. +.if t \{ +.EQ +F over l = 2 k sub roman A { I sub 1 I sub 2 } over r . +.EN +.\} +.RE +.PP +.PP +The two constants, +.if n \fIk\fP_C and \fIk\fP_A, +.if t $k sub roman C$ and $k sub roman A$, +are related by the square of the speed of light: +.if n \fIk\fP_A\ =\ \fIk\fP_C\ /\ \fIc\fP^2. +.if t $k sub roman A = k sub roman C / c sup 2$. +.PP +In the SI, the constants have dimensions, and an additional base unit, +the ampere, measures electric current. The CGS systems do not define +new base units, but express charge and current as derived units in +terms of mass, length, and time. In the ESU system, the constant for +Coulomb's law is chosen to be unity and dimensionless, which defines +the unit of charge. In the EMU system, the constant for Ampere's law +is chosen to be unity and dimensionless, which defines a unit of +current. The Gaussian system usually uses the ESU units for charge +and current; it chooses another constant so that the units for the +electric and magnetic fields are the same. +.PP +The dimensions of electrical quantities in the various CGS systems are +different from the SI dimensions for the same units; +strictly, conversions between these systems and SI are not possible. +But units in different systems relate to the same physical quantities, +so there is a \fIcorrespondence\fP between these units. +The +.CW "units" +program defines the units so that you can convert +between corresponding units in the various systems. +.PP +.SS Specifying CGS Units +The CGS definitions involve +.if n cm^(1/2) and g^(1/2), +.if t cm$"" sup {1/2}$ and g$"" sup {1/2}$, +which is problematic because +.CW "units" +does not normally support +fractional roots of base units. The +.CQ "--units" +.CQ ( "-u" ) +option allows selection of a CGS unit system and works around this +restriction by introducing base units for the square roots of +length and mass: +.CQ "sqrt_cm" +and +.CQ "sqrt_g" . +The centimeter +then becomes +.CQ "sqrt_cm^2" +and the gram, +.CQ "sqrt_g^2" . +This allows working from +equations using the units in the CGS system, and +enforcing dimensional conformity within that system. Recognized +arguments to the +.CQ "--units" +option are +.CQ "gauss[ian]" , +.CQ "esu" , +.CQ "emu" , +and +.CQ "si" ; +the argument is case insensitive. +The default mode for +.CW "units" +is SI units; the only effect of +giving +.CQ "si" +with the +.CQ "--units" +option is to prepend +.CQ "(SI)" +to the +.CQ "You\ have:" +prompt. Giving an unrecognized +system generates a warning, and +.CW "units" +uses SI units. +.PP +The changes resulting from the +.CQ "--units" +option are actually +controlled by the +.CW "UNITS_SYSTEM" +environment variable. If you +frequently work with one of the supported CGS units systems, you may set +this environment variable rather than giving the +.CQ "--units" +option +at each invocation. As usual, an option given on the command line +overrides the setting of the environment variable. For example, if you would +normally work with Gaussian units but might occasionally work with +SI, you could set +.CW "UNITS_SYSTEM" +to +.CQ "gaussian" +and specify +SI with the +.CQ "--units" +option. +Unlike the argument to the +.CQ "--units" +option, the value of +.CW "UNITS_SYSTEM" +\fIis\fP case sensitive, so setting a value of +.CQ "EMU" +will have no effect other than to give an error message and +set SI units. +.PP +The CGS definitions appear as conditional settings in the standard +units data file, which you can consult for more information on how +these units are defined, or on how to define an alternate units system. +.PP +.SS CGS Units Systems +The ESU system derives the electromagnetic units from its unit of +charge, the statcoulomb, +which is defined from +Coulomb's law. The statcoulomb equals +.if n dyne^(1/2)\ cm, or cm^(3/2)\ g^(1/2)\ s^(\(mi1). +.if t $roman dyne sup {1/2} ^ roman cm$, +.if t or $roman cm sup {3/2} ^ roman g sup {1/2} ^ roman s sup {-1}$. +The unit of current, the statampere, is statcoulomb\ sec, analogous to +the relationship in SI. Other electrical units are then derived in a +manner similar to that for SI units; the units use the SI names prefixed +by +.CQ "stat-" , +e.g., +.CQ "statvolt" +or +.CQ "statV" . +The prefix +.CQ "st-" +is also recognized (e.g., +.CQ "stV" ). +.PP +The EMU system derives the electromagnetic units from its unit of current, +the abampere, which is defined in terms of Ampere's law. The abampere +is equal to +.if n dyne^(1/2), or cm^(1/2)\ g^(1/2)\ s^(\(mi1). +.if t $roman dyne sup {1/2}$, +.if t or $roman cm sup {1/2} ^ roman g sup {1/2} ^ roman s sup{-1}$. +.EQ +delim off +.EN +The unit of charge, the abcoulomb, is +abampere\ sec, again analogous to the SI relationship. +Other electrical units are then derived in a +manner similar to that for SI units; the units use the SI names prefixed +by +.CQ "ab-" , +e.g., +.CQ "abvolt" +or +.CQ "abV" . +The magnetic field +units include the gauss, the oersted and the maxwell. +.PP +The Gaussian units system, which was also known as the Symmetric +System, +uses the same charge and current units as the ESU system (e.g., +.CQ "statC" , +.CQ "statA" ); +it differs by defining the magnetic field +so that it has the same units as the electric field. The resulting +magnetic field units are the same ones used in the EMU system: the +gauss, the oersted and the maxwell. +.PP +.SS Conversions Between Different Systems +The CGS systems define units that measure the same thing but may have +conflicting dimensions. Furthermore, the dimensions of the +electromagnetic CGS units are never compatible with SI. +But if you measure charge in two different systems you have measured the +same physical thing, so there is a \fIcorrespondence\fP between the +units in the different systems, and +.CW "units" +supports conversions +between corresponding units. When running with SI, +.CW "units" +defines all of the CGS units in terms of SI. When you select a CGS +system, +.CW "units" +defines the SI units and the other CGS system +units in terms of the system you have selected. +.PP +.ES +(Gaussian) You have: statA + You want: abA + * 3.335641e-11 + / 2.9979246e+10 +(Gaussian) You have: abA + You want: sqrt(dyne) +conformability error + 2.9979246e+10 sqrt_cm^3 sqrt_g / s^2 + 1 sqrt_cm sqrt_g / s +.EE +.PP +In the above example, +.CW "units" +converts between the current +units statA and abA even though the abA, from the EMU system, has +incompatible dimensions. This works because in Gaussian mode, the abA +is defined in terms of the statA, so it does not have the correct +definition for EMU; consequently, you cannot convert the abA to its EMU +definition. +.PP +One challenge of conversion is that because +the CGS system has fewer base units, quantities that have different +dimensions in SI may have the same dimension in a CGS system. And +yet, they may not have the same conversion factor. For example, the +unit for the E field and B fields are the same in the +Gaussian system, but the conversion factors to SI are quite +different. This means that correct conversion is only possible if you +keep track of what quantity is being measured. You cannot convert +statV/cm to SI without indicating which type of field the unit +measures. To aid in dimensional analysis, +.CW "units" +defines +various dimension units such as LENGTH, TIME, and CHARGE to be the +appropriate dimension in SI. The +electromagnetic dimensions such as B_FIELD or E_FIELD may be useful +aids both for conversion and dimensional analysis in CGS. You +can convert them to or from CGS in order to perform SI conversions +that in some cases will not work directly due to dimensional incompatibilities. +This example shows how the Gaussian system uses the same units for all +of the fields, but they all have different conversion factors with +SI. +.PP +.ES +(Gaussian) You have: statV/cm + You want: E_FIELD + * 29979.246 + / 3.335641e-05 +(Gaussian) You have: statV/cm + You want: B_FIELD + * 0.0001 + / 10000 +(Gaussian) You have: statV/cm + You want: H_FIELD + * 79.577472 + / 0.012566371 +(Gaussian) You have: statV/cm + You want: D_FIELD + * 2.6544187e-07 + / 3767303.1 +.EE +.PP +The next example shows that the oersted cannot be converted directly +to the SI unit of magnetic field, A/m, because the dimensions +conflict. We cannot redefine the ampere to make this work because +then it would not convert with the statampere. But you can still do +this conversion as shown below. +.PP +.ES +(Gaussian) You have: oersted + You want: A/m +conformability error + 1 sqrt_g / s sqrt_cm + 29979246 sqrt_cm sqrt_g / s^2 +(Gaussian) You have: oersted + You want: H_FIELD + * 79.577472 + / 0.012566371 +.EE +.PP +.SS Prompt Prefix +If a unit system is specified with the +.CQ "--units" +option, the +selected system's name is prepended to the +.CQ "You\ have:" +prompt +as a reminder, e.g., +.PP +.ES +(Gaussian) You have: stC + You want: + Definition: statcoulomb = sqrt(dyne) cm = 1 sqrt_cm^3 sqrt_g / s +.EE +.PP +You can suppressed the prefix by including a line +.PP +.ES +!prompt +.EE +.PP +with no argument in a site or personal units data file. The prompt can +be conditionally suppressed by including such a line within +.CQ "!var" +... +.CQ "!endvar" +constructs, e.g., +.PP +.ES +!var UNITS_SYSTEM gaussian gauss +!prompt +!endvar +.EE +.PP +This might be appropriate if you normally use Gaussian units and find +the prefix distracting but want to be reminded when you have selected a +different CGS system. +.PP .SH LOGGING CALCULATIONS The .CQ "--log" @@ -1998,7 +2508,11 @@ display the definition of that unit and exit. Units specified on the command line may need to be quoted to protect them from shell interpretation and to group -them into two arguments. See \fICommand Line Use\fP. +them into two arguments. Note also that the +.CQ "--quiet" +option +is enabled by default if you specify \fIfrom-unit\fP on the command line. +See \fICommand Line Use\fP. .PP The default behavior of .CW "units" @@ -2064,7 +2578,6 @@ exponential format with the default eight significant digits). .PP The following options are available: -.PP .TP .BR "-\^c" ", " "-\^-\^check" Check that all units and prefixes defined in the units data file reduce @@ -2074,7 +2587,6 @@ in the current locale are checked. You should always run .CW "units" with this option after modifying a units data file. -.PP .TP .BR "-\^-\^check-verbose" ", " "-\^-\^verbose-check" Like the @@ -2087,7 +2599,6 @@ .CW "units" hangs, then the last unit to be printed has a bad definition. Only definitions active in the current locale are checked. -.PP .TP .BR "-\^d \fIndigits\fP" ", " "-\^-\^digits \fIndigits\fP" Set the number of significant digits in the output to the value @@ -2110,14 +2621,13 @@ (e.g., .CQ "-d\ max" ). Be aware, of course, that -``significant'' here refers only to the \fIdisplay\fP of numbers; if +\*(lQsignificant\*(rQ here refers only to the \fIdisplay\fP of numbers; if results depend on physical constants not known to this precision, the physically meaningful precision may be less than that shown. The .CQ "--digits" option conflicts with the .CQ "--output-format" option. -.PP .TP .BR "-\^e" ", " "-\^-\^exponential" Set the numeric output format to exponential (i.e., scientific @@ -2132,7 +2642,6 @@ option conflicts with the .CQ "--output-format" option. -.PP .TP .BR "-\^o \fIformat\fP" ", " "-\^-\^output-format \fIformat\fP" This option affords complete control over the numeric output format @@ -2192,7 +2701,6 @@ and .CQ "--digits" options. -.PP .TP .BR "-\^f \fIfilename\fP" ", " "-\^-\^file \fIfilename\fP" Instruct @@ -2212,7 +2720,6 @@ will be loaded in addition to any others specified with .CQ "-f" . -.PP .TP .BR "-\^L \fIlogfile\fP" ", " "-\^-\^log \fIlogfile\fP" Save the results of calculations in the file \fIlogfile\fP; this can be @@ -2225,7 +2732,6 @@ is used non-interactively. See \fILogging Calculations\fP for a more detailed description and some examples. -.PP .TP .BR "-\^H \fIfilename\fP" ", " "-\^-\^history \fIfilename\fP" Instruct @@ -2238,19 +2744,16 @@ .CQ ( "-H\ """"" ). This option has no effect if readline is not available. -.PP .TP .BR "-\^h" ", " "-\^-\^help" Print out a summary of the options for .CW "units" . -.PP .TP .BR "-\^m" ", " "-\^-\^minus" Causes .CQ "-" to be interpreted as a subtraction operator. This is the default behavior. -.PP .TP .BR "-\^p" ", " "-\^-\^product" Causes @@ -2263,7 +2766,6 @@ .CQ "-" is treated as a subtraction operator. -.PP .TP .BR "-\^-\^oldstar" Causes @@ -2273,7 +2775,6 @@ .CQ "1/2*3" will equal .CQ "1/6" . -.PP .TP .BR "-\^-\^newstar" Forces @@ -2288,28 +2789,10 @@ .CQ "1/2*3" will equal .CQ "3/2" . -.PP -.TP -.BR "-\^-\^compact" -Give compact output featuring only the conversion factor. This turns -off the -.CQ "--verbose" -option. -.PP -.TP -.BR "-\^q" ", " "-\^-\^quiet" ", " "-\^-\^silent" -Suppress prompting of the user for units and the display of statistics -about the number of units loaded. -.PP -.TP -.BR "-\^n" ", " "-\^-\^nolists" -Disable conversion to unit lists. -.PP .TP .BR "-\^r" ", " "-\^-\^round" When converting to a combination of units given by a unit list, round the value of the last unit in the list to the nearest integer. -.PP .TP .BR "-\^S" ", " "-\^-\^show-factor" When converting to a combination of units specified in a list, @@ -2343,43 +2826,7 @@ whether or not the .CQ "--show-factor" option is given. -.PP -.TP -.BR "-\^s" ", " "-\^-\^strict" -Suppress conversion of units to their reciprocal units. For -example, -.CW "units" -will normally convert hertz to seconds -because these units are reciprocals of each other. The strict option -requires that units be strictly conformable to perform a conversion, and -will give an error if you attempt to convert hertz to seconds. -.PP -.TP -.BR "-\^1" ", " "-\^-\^one-line" -Give only one line of output (the forward conversion). Do not print -the reverse conversion. If a reciprocal conversion is -performed then -.CW "units" -will still print the ``reciprocal -conversion'' line. -.PP -.TP -.BR "-\^t" ", " "-\^-\^terse" -Give terse output when converting units. This option can be used when -calling -.CW "units" -from another program so that the output is easy to -parse. This option has the combined -effect of these options: -.CQ "--strict" -.CQ "--quiet" -.CQ "--one-line" -.CQ "--compact" . -When combined with -.CQ "--version" -it produces -a display showing only the program name and version number. -.PP +.IP .TP .BR "-\^v" ", " "-\^-\^verbose" Give slightly more verbose output when converting units. When combined @@ -2392,7 +2839,6 @@ produces a more detailed output, equivalent to the .CQ "--info" option. -.PP .TP .BR "-\^V" ", " "-\^-\^version" Print the program version number, tell whether the @@ -2401,12 +2847,12 @@ give the locale, the location of the default units data file, and the location of the personal units data file; indicate if the personal units data file does not exist. -.PP +.IP When given in combination with the .CQ "--terse" option, the program prints only the version number and exits. -.PP +.IP When given in combination with the .CQ "--verbose" option, the @@ -2415,7 +2861,6 @@ option has the same effect as the .CQ "--info" option below. -.PP .TP .BR "-\^I" ", " "-\^-\^info" Print the information given with the @@ -2435,7 +2880,7 @@ variable and information about the related locale map are also given. This option is usually of interest only to developers and administrators, but it can sometimes be useful for troubleshooting. -.PP +.IP Combining the .CQ "--version" and @@ -2443,23 +2888,214 @@ options has the same effect as giving .CQ "--info" . -.PP .TP .BR "-\^U" ", " "-\^-\^unitsfile" Print the location of the default units data file and exit; if the file -cannot be found, print ``Units data file not found''. -.PP +cannot be found, print \*(lQUnits data file not found\*(rQ. +.TP +.BR "-\^u (gauss[ian]|esu|emu)" ", " "-\^-\^units (gauss[ian]|esu|emu)" +Specify a CGS units system: Gaussian, ESU, or EMU. .TP .BR "-\^l \fIlocale\fP" ", " "-\^-\^locale \fIlocale\fP" -Print the information given with the -.CQ "--version" -option, show the Force a specified locale such as .CQ "en_GB" to get British definitions by default. This overrides the locale determined from system settings or environment variables. See \fILocale\fP for a description of locale format. +.TP +.BR "-\^n" ", " "-\^-\^nolists" +Disable conversion to unit lists. +.TP +.BR "-\^s" ", " "-\^-\^strict" +Suppress conversion of units to their reciprocal units. For +example, +.CW "units" +will normally convert hertz to seconds +because these units are reciprocals of each other. The strict option +requires that units be strictly conformable to perform a conversion, and +will give an error if you attempt to convert hertz to seconds. +.TP +.BR "-\^1" ", " "-\^-\^one-line" +Give only one line of output (the forward conversion); do not print +the reverse conversion. If a reciprocal conversion is +performed, then +.CW "units" +will still print the \*(lQreciprocal +conversion\*(rQ line. +.TP +.BR "-\^t" ", " "-\^-\^terse" +Print only a single conversion factor. This option can be used when +calling +.CW "units" +from another program so that the output is easy to +parse. This option has the combined +effect of these options: +.CQ "--strict" +.CQ "--quiet" +.CQ "--one-line" +.CQ "--compact" . +When combined with +.CQ "--version" +it produces +a display showing only the program name and version number. +.TP +.BR "-\^-\^compact" +Give compact output featuring only the conversion factor; the +multiplication and division signs are not shown, and there is no leading +whitespace. If you convert to a unit list, then the output is a +semicolon separated list of factors. +This turns off the +.CQ "--verbose" +option. +.TP +.BR "-\^q" ", " "-\^-\^quiet" ", " "-\^-\^silent" +Suppress the display of statistics about the number of units loaded, +any messages printed by the units database, +and the prompting of the user for units. This option does not +affect how +.CW "units" +displays the results. This option is +turned on by default if you invoke +.CW "units" +with a unit +expression on the command line. +.IP +.SH OUTPUT STYLES +The output can be tweaked in various ways using command line options. +With no options, the output looks like this +.PP +.ES +$ units +Currency exchange rates from FloatRates (USD base) on 2019-02-20 +3070 units, 109 prefixes, 109 nonlinear units + +You have: 23ft +You want: m + * 7.0104 + / 0.14264521 +You have: m +You want: ft;in + 3 ft + 3.3700787 in +.EE +.PP +This is arguably a bit cryptic; the +.CQ "--verbose" +option makes clear what the output means: +.PP +.ES +$ units --verbose +Currency exchange rates from FloatRates (USD base) on 2019-02-20 +3070 units, 109 prefixes, 109 nonlinear units + +You have: 23 ft +You want: m + 23 ft = 7.0104 m + 23 ft = (1 / 0.14264521) m +You have: meter +You want: ft;in + meter = 3 ft + 3.3700787 in +.EE +.PP +The +.CQ "--quiet" +option suppresses the clutter displayed when +.CW "units" +starts, as well as the prompts to the user. +This option is enabled by default when you +give units on the command line. +.PP +.ES +$ units --quiet +23 ft +m + * 7.0104 + / 0.14264521 + +$ units 23ft m + * 7.0104 + / 0.14264521 +.EE +.PP +The remaining style options allow you to display only numerical values +without the tab or the multiplication and division signs, or to display just a +single line showing the forward conversion: +.aQ +.PP +.ES +$ units --compact 23ft m +7.0104 +0.14264521 + +$ units --compact m 'ft;in' +3;3.3700787 + +$ units --one-line 23ft m + * 7.0104 + +$ units --one-line 23ft 1/m + reciprocal conversion + * 0.14264521 + +$ units --one-line 23ft kg +conformability error + 7.0104 m + 1 kg +.EE +.PP +Note that when converting to a unit list, the +.CQ "--compact" +option displays a semicolon separated list of results. Also be aware +that the +.CQ "one-line" +option doesn't live up to its name if you +execute a reciprocal conversion or if you get a conformability error. +The former case can be prevented using the +.CQ "--strict" +option, +which suppresses reciprocal conversions. +Similarly you can suppress unit list conversion using +.CQ "--nolists" . +It is impossible to prevent +the three line error output. +.PP +.ES +$ units --compact --nolists m 'ft;in' +Error in 'ft;in': Parse error + +$ units --one-line --strict 23ft 1/m +.EE +.PP +The various style options can be combined appropriately. The ultimate +combination is the +.CQ "--terse" +option, which combines +.CQ "--strict" , +.CQ "--quiet" , +.CQ "--one-line" , +and +.CQ "--compact" +to produce the minimal output, +just a single number for regular conversions and a semicolon +separated list for conversion to unit lists. This will likely be the +best choice for programs that want to call +.CW "units" +and then +process its result. +.PP +.ES +$ units --terse 23ft m +7.0104 + +$ units --terse m 'ft;in' +3;3.3700787 + +$ units --terse 23ft 1/m +conformability error +7.0104 m +1 / m +.EE +.aE .PP .SH ADDING YOUR OWN DEFINITIONS .SS Units Data Files @@ -2560,7 +3196,7 @@ must be the first character on the line. The file will be sought in the same directory as the parent file unless you give a full path. The name of the file to be -included cannot contain the comment character +included cannot contain spaces or the comment character .CQ "#" . .PP Unit names must not contain any of the operator characters @@ -2633,7 +3269,8 @@ .PP If you define any units that contain .CQ "+" -characters, carefully check them because the +characters in their definitions, +carefully check them because the .CQ "-c" option will not catch non-conformable sums. Be careful with the @@ -2661,6 +3298,21 @@ or even .CQ "foo+-bar" . .PP +You may wish to intentionally redefine a unit. When you do this, and +use the +.CQ "-c" +option, +.CW "units" +displays a warning message +about the redefinition. You can suppress these warnings by redefining +a unit using a +.CQ "+" +at the beginning of the unit name. Do not +include any white space between the +.CQ "+" +and the redefined unit +name. +.PP Here is an example of a short data file that defines some basic units: .PP @@ -2671,9 +3323,10 @@ micro- 1e-6 # Define a prefix minute 60 sec # A minute is 60 seconds hour 60 min # An hour is 60 minutes -inch 0.0254 m # Inch defined in terms of meters +inch 72 m # Inch defined incorrectly terms of meters ft 12 inches # The foot defined in terms of inches mile 5280 ft # And the mile ++inch 0.0254 m # Correct redefinition, warning suppressed .EE .PP A unit that ends with a @@ -2683,7 +3336,7 @@ .CQ "/" characters, be sure they are protected by parentheses. If you define -.CQ "half- 1/2" +.CQ "half- 1/2" , then .CQ "halfmeter" would be equivalent to @@ -2864,7 +3517,7 @@ parameter value of 900\ mm for comparison. Without units, numerical values other than zero or plus or minus infinity for domain or range endpoints are meaningless, and accordingly they are not allowed. If -you give other values without units then the definition will be ignored +you give other values without units, then the definition will be ignored and you will get an error message. .PP Although the units, domain, and range specifications are optional, it's @@ -3014,6 +3667,7 @@ arbitrary combination of units, as well as the square and cube of that combination; a warning is given if any of these tests fail. For example, +.aQ .PP .ES Warning: function 'squirt(x)' defined as 'sqrt(x)' @@ -3021,6 +3675,7 @@ squirt(7(kg K)^1): Unit not a root squirt(7(kg K)^3): Unit not a root .EE +.aE .PP Running .CW "units\ --check" @@ -3040,10 +3695,12 @@ Running .CW "units\ --check" would give the error message +.aQ .PP .ES Table 'ansicoated' lacks unique inverse around entry 800 .EE +.aE .PP Although the inverse is not well defined in this region, it's not really an error. Viewing such error messages can be tedious, and if there are @@ -3369,7 +4026,7 @@ .EE .PP .SS Precision -The meaning of ``precision'' depends on the format type. With +The meaning of \*(lQprecision\*(rQ depends on the format type. With .CQ "g" or .CQ "G" , @@ -3579,7 +4236,7 @@ environment variable does \fInot\fP equal any of the list values. .PP The inch has long been a customary measure of length in many places. -The word comes from the latin \fIuncia\fP meaning ``one twelfth,'' +The word comes from the Latin \fIuncia\fP meaning \*(lQone twelfth,\*(rQ referring to its relationship with the foot. By the 20th century, the inch was officially defined in English-speaking countries relative to the yard, but until 1959, the yard differed slightly among those @@ -3620,7 +4277,7 @@ the appropriate section. If .CW "INCH_UNIT" is unset or is not set to -one of the four values listed then +one of the four values listed, then .CW "units" will run the last block. In this case that block uses the @@ -3637,7 +4294,7 @@ .CW "units" invocation and do not persist. So if the example above were preceded by -.CQ "!set INCH_UNIT france" +.CQ "!set INCH_UNIT france" , then this would make .CQ "france" the @@ -3688,7 +4345,7 @@ .CQ "!var" or .CQ "!varnot" -is undefined +is undefined, then .CW "units" prints an error message and ignores the @@ -3705,7 +4362,6 @@ The .CW "units" program uses the following environment variables: -.PP .TP .BR "HOME" Specifies the location of your home directory; it is used by @@ -3733,7 +4389,6 @@ Vista and Windows\ 7) or .CQ "C:\eDocuments\ and\ Settings\e\fIusername\fP" (Windows\ XP). -.PP .TP .BR "LC_CTYPE, LANG" Checked to determine the locale if @@ -3741,7 +4396,6 @@ cannot obtain it from the operating system. Sections of the standard units data file are specific to certain locales. -.PP .TP .BR "MYUNITSFILE" Specifies your personal units data file. If this variable exists, @@ -3753,7 +4407,6 @@ loaded if any data files are given using the .CQ "-f" option. -.PP .TP .BR "PAGER" Specifies the pager to use for help and for displaying the conformable @@ -3771,7 +4424,6 @@ .CW "emacs" , or .CW "vi" . -.PP .TP .BR "UNITS_ENGLISH" Set to either @@ -3780,7 +4432,6 @@ .CQ "GB" to choose United States or British volume definitions, overriding the default from your locale. -.PP .TP .BR "UNITSFILE" Specifies the units data file to use (instead of the default). @@ -3794,7 +4445,6 @@ .CQ "-f" option is given with the empty string .CQ ( "units\ -f\ """"" ). -.PP .TP .BR "UNITSLOCALEMAP" Windows only; this variable has no effect on Unix-like systems. @@ -3807,7 +4457,18 @@ .CW "UNITSFILE" environment variable, and that location does not also contain the locale map file. -.PP +.TP +.BR "UNITS_SYSTEM" +This environment variable is used in the standard data file to select +CGS measurement systems. Currently supported systems are +.CQ "esu" , +.CQ "emu" , +.CQ "gauss[ian]" , +and +.CQ "si" . +The default is +.CQ "si" . +.IP .SH DATA FILES The .CW "units" @@ -3832,7 +4493,9 @@ .CQ "/usr/local/share/units" if .CW "units" -is compiled from the source distribution. +is compiled from the source distribution. Note that the currency file +.CQ "currency.units" +is a symbolic link to another location. .PP On systems running Microsoft Windows, the files may be in the same locations if Unix-like commands are available, a Unix-like file @@ -3888,53 +4551,58 @@ and ending with .CQ "!endutf8" . .PP -When +The non-ASCII definitions are loaded only if the platform and the locale +support UTF-8. Platform support is determined when +.CW "units" +is compiled; the locale is checked at every invocation of +.CW "units" . +To see if your version of +.CW "units" +includes +Unicode support, invoke the program with the +.CQ "--version" +option. +.PP +When Unicode support is available, .CW "units" -starts, it checks the locale to determine the -character set. If +checks every line +within UTF-8 blocks in all of the units data files for invalid or +non-printing UTF-8 sequences; if such sequences occur, .CW "units" -is compiled with Unicode support and -definitions; otherwise these definitions are ignored. When Unicode -support is active, -.CW "units" -will check every line of all of the -units data files for invalid or non-printing UTF-8 sequences; if such -sequences occur, -.CW "units" -ignores the entire line. In addition -to checking validity, -.CW "units" -determines the display width of -non-ASCII characters to ensure proper positioning of the pointer in some -error messages and to align columns for the +ignores the entire line. In addition to checking validity, +.CW "units" +determines the display width of non-ASCII characters to +ensure proper positioning of the pointer in some error messages and to +align columns for the .CQ "search" and .CQ "?" commands. .PP -At present, +As of early 2019, Microsoft Windows provides limited support for UTF-8 +in console applications, and accordingly, .CW "units" -does not support Unicode under Microsoft -Windows. The UTF-16 and UTF-32 encodings are not supported on any -systems. -.PP -If definitions that contain non-ASCII characters are added to a units -data file, those definitions should be enclosed within +does not +support Unicode on Windows. The UTF-16 and UTF-32 encodings are not +supported on any platforms. +.PP +If Unicode support is available and definitions that contain non-ASCII +UTF-8 characters are added to a units data file, those definitions +should be enclosed within .CQ "!utf8" \*(El .CQ "!endutf8" -to ensure that they are only loaded when -Unicode support is available. As usual, the +to ensure +that they are only loaded when Unicode support is available. As usual, +the .CQ "!" -must appear as -the first character on the line. As discussed in -\fIUnits Data Files\fP, it's usually best to put such definitions in -supplemental data files linked by an +must appear as the first character on the line. As +discussed in \fIUnits Data Files\fP, it's usually best to put such +definitions in supplemental data files linked by an .CQ "!include" -command or in a -personal units data file. +command or in a personal units data file. .PP -When Unicode support is not active, +When Unicode support is not available, .CW "units" makes no assumptions about character encoding, except that characters in the range 00\-7F @@ -3945,14 +4613,15 @@ characters in definitions when running .CW "units" under Windows, -you can use a character set such as Windows ``ANSI'' (code page 1252 in -the US and Western Europe). You can even use UTF-8, though some -messages may be improperly aligned, and -.CW "units" -will not detect -invalid UTF-8 sequences. If you use UTF-8 encoding when Unicode support -is not active, you should place any definitions with non-ASCII -characters \fIoutside\fP +you can use a character set such as Windows \*(lQANSI\*(rQ (code page 1252 in +the US and Western Europe); if this is done, the console code page must +be set to the same encoding for the characters to display properly. +You can even use UTF-8, though some messages may be improperly aligned, +and +.CW "units" +will not detect invalid UTF-8 sequences. If you use +UTF-8 encoding when Unicode support is not available, you should place any +definitions with non-ASCII characters \fIoutside\fP .CQ "!utf8" \*(El .CQ "!endutf8" @@ -3998,7 +4667,7 @@ commands. .PP If you type a few characters and then hit \fIESC\fP followed by -.CI "?" +.CI "?" , then .CW "units" will display a list of all the units that @@ -4015,7 +4684,7 @@ You have: metr .EE .PP -If there is a unique way to complete a unitname, you can hit the \fITAB\fP key +If there is a unique way to complete a unit name, you can hit the \fITAB\fP key and .CW "units" will provide the rest of the unit name. If @@ -4048,43 +4717,149 @@ its new history to the history file upon exit. .PP .SH UPDATING CURRENCY EXCHANGE RATES -The units program includes currency exchange rates and prices for some -precious metals in the database. Of course, these values change over -time, sometimes very rapidly, and +.na +The units program database includes currency exchange rates and prices +for some precious metals. Of course, these values change over time, +sometimes very rapidly, and .CW "units" -cannot provide real -time values. To update the exchange rates run the +cannot provide real-time +values. To update the exchange rates, run .CW "units_cur" , -which rewrites the files containing the currency -rates, typically -.CQ "/usr/share/units/currency.units" . -This program -requires -.CW "python" , -and must -be run with suitable permissions to write the file. To keep the rates -updated automatically, run it using a cron job on a Unix-like system, or -a similar scheduling program on a different system. Currency exchange -rates are taken from Yahoo (\fRhttp://finance.yahoo.com\fP) and -precious metals pricing from Packetizer (\fRwww.packetizer.com\fP). -These sites update once per day, so there is no benefit in running the -update script more often than daily. You can run +which +rewrites the file containing the currency rates, typically +.CQ "/var/lib/\:units/\:currency.units" +or +.CQ "/usr/local/\:com/\:units/\:currency.units" +on a Unix-like system or +.CQ "C:\eProgram\ Files\ (x86)\e\:GNU\e\:units\e\:definitions.units" +on a Windows +system. +.ad b +.PP +This program requires Python (\fRhttps://www.python.org\fP); either +version 2 or 3 will work. The program must be run with suitable +permissions to write the file. To keep the rates updated automatically, +run it using a cron job on a Unix-like system, or a similar scheduling +program on a different system. +.PP +Reliable free sources of currency exchange rates have been annoyingly +ephemeral. The program currently supports several sources: +.PP +.IP \h'1n'\(bu 4n +FloatRates (\fRhttps://www/floatrates.com\fP). +The US dollar +.CQ ( "USD" ) +is the default base currency. You can +change the base currency with the +.CQ "-b" +option described below. Allowable base currencies are listed on +the FloatRates website. Exchange rates update daily. +.PP +.IP \h'1n'\(bu 4n +The European Central Bank (\fRhttps://www.ecb.europa.eu\fP). +The base currency is always the euro +.CQ ( "EUR" ). +Exchange rates +update daily. This source offers a more limited list of currencies +than the others. +.PP +.IP \h'1n'\(bu 4n +Fixer (\fRhttps://fixer.io\fP). +Registration for a free API key is required. With a free API key, base +currency is the euro; exchange rates are updated hourly, the +service has a limit of 1,000 API calls per month, and SSL encryption +(https protocol) is not available. Most of these restrictions are +eliminated or reduced with paid plans. +.PP +.IP \h'1n'\(bu 4n +open exchange rates (\fRhttps://openexchangerates.org\fP). +Registration for a free API key is required. With a free API key, the +base currency is the US dollar; exchange rates are updated hourly, and +there is a limit of 1,000 API calls per month. Most of these +restrictions are eliminated or reduced with paid plans. +.PP +The default source is FloatRates; you can select a different one using +.CQ "-s" +option described below. +.PP +Precious metals pricing is obtained from Packetizer +(\fRwww.packetizer.com\fP). This site updates once per day. +.PP +You invoke +.CW "units_cur" +like this: +.PP +.ES +units_cur [\fIoptions\fP] [\fIoutfile\fP] +.EE +.PP +By default, the output is written to the default currency file described +above; this is usually what you want, because this is where +.CW "units" +looks for the file. If you wish, you can specify a +different filename on the command line and .CW "units_cur" -with a filename specified on the command line and it will write the data -to that file. If you give +will +write the data to that file. If you give .CQ "-" -for the file it will write to -standard output. +for the file it will +write to standard output. .PP +The following options are available: +.TP +.BR "-\^h" ", " "-\^-\^help" +Print a summary of the options for +.CW "units_cur" . +.TP +.BR "-\^V" ", " "-\^-\^version" +Print the +.CW "units_cur" +version number. +.TP +.BR "-\^v" ", " "-\^-\^verbose" +Give slightly more verbose output when attempting to update currency +exchange rates. +.TP +.BR "-\^s \fIsource\fP" ", " "-\^-\^source \fIsource\fP" +Specify the source for currency exchange rates; currently supported +values are +.CQ "floatrates" +(for FloatRates), +.CQ "eubank" +(for the +European Central Bank), +.CQ "fixer" +(for Fixer), and +.CQ "openexchangerates" +(for open exchange rates); the last two require +an API key to be given with the +.CQ "-k" +option. +.TP +.BR "-\^b \fIbase\fP" ", " "-\^-\^base \fIbase\fP" +Set the base currency (when allowed by the site providing the data). +\fIbase\fP should be a 3-letter ISO currency code, e.g., +.CQ "USD" . +The specified currency will be the primitive currency unit used by +.CW "units" . +You may find it convenient to specify your local +currency. Conversions may be more accurate and you will be able to +convert to your currency by simply hitting \fIEnter\fP at the +.CQ "You\ want:" +prompt. This option is ignored if the source +does not allow specifying the base currency. (Currently only +floatrates supports this option.) +.TP +.BR "-\^k \fIkey\fP" ", " "-\^-\^key \fIkey\fP" +Set the API key to \fIkey\fP for sources that require it. +.IP .SH DATABASE COMMAND SYNTAX .TP .BR "\fIunit\fP \fIdefinition\fP" Define a regular unit. -.PP .TP .BR "\fIprefix\fP- \fIdefinition\fP" Define a prefix. -.PP .TP .BR "\fIfuncname\fP(\fIvar\fP) noerror units=[\fIin-\^units\fP,\fIout-units\fP] domain=[\fIx1\fP,\fIx2\fP] range=[\fIy1\fP,\fIy2\fP] \fIdefinition(var)\fP ; \fIinverse(funcname)\fP" Define a nonlinear unit or unit function. The four optional keywords @@ -4095,7 +4870,6 @@ .CW "domain=" can appear in any order. The definition of the inverse is optional. -.PP .TP .BR "\fItabname\fP[\fIout-\^units\fP] noerror \fIpair-list\fP" Define a piecewise linear unit. The pair list gives the points on the @@ -4103,56 +4877,54 @@ .CW "noerror" keyword is optional. -.PP .TP .BR "!endlocale" End a block of definitions beginning with .CQ "!locale" -.PP .TP .BR "!endutf8" End a block of definitions begun with .CQ "!utf8" -.PP .TP .BR "!endvar" End a block of definitions begun with .CQ "!var" or .CQ "!varnot" -.PP .TP .BR "!include \fIfile\fP" Include the specified file. -.PP .TP .BR "!locale \fIvalue\fP" Load the following definitions only of the locale is set to \fIvalue\fP. -.PP .TP .BR "!message \fItext\fP" Display \fItext\fP when the database is read unless the quiet option .CQ ( "-q" ) -is enabled. -.PP +is enabled. If you omit \fItext\fP, then units +will display a blank line. Messages will also appear in the log +file. +.TP +.BR "!prompt \fItext\fP" +Prefix the +.CQ "You\ have:" +prompt with the specified text. If +you omit \fItext\fP, then any existing prefix is canceled. .TP .BR "!set \fIvariable\fP \fIvalue\fP" Sets the environment variable, \fIvariable\fP, to the specified value \fIonly if\fP it is not already set. -.PP .TP .BR "!unitlist \fIalias\fP \fIdefinition\fP" Define a unit list alias. -.PP .TP .BR "!utf8" Load the following definitions only if .CW "units" is running with UTF-8 enabled. -.PP .TP .BR "!var \fIenvar\fP \fIvalue-\^list\fP" Load the block of definitions that follows only if the environment @@ -4161,7 +4933,6 @@ .CW "units" prints an error message and ignores the block of definitions. -.PP .TP .BR "!varnot \fIenvar\fP \fIvalue-\^list\fP" Load the block of definitions that follows only if the environment @@ -4169,8 +4940,9 @@ space-separated value list. If \fIenvar\fP is not set, .CW "units" prints an error message and ignores the block of definitions. -.PP -.SH GNU FREE DOCUMENTATION LICENSE +.IP .SH FILES @DATAFILE@ \(em the standard units data file .SH AUTHOR +.I units +was written by Adrian Mariano Binary files /tmp/tmp5EHtQ4/72Ux5uwBEZ/units-2.16/UnitsMKS.pdf and /tmp/tmp5EHtQ4/0mofb4A4hK/units-2.19/UnitsMKS.pdf differ diff -Nru units-2.16/UnitsMKS.texinfo units-2.19/UnitsMKS.texinfo --- units-2.16/UnitsMKS.texinfo 2017-11-01 01:44:28.000000000 +0000 +++ units-2.19/UnitsMKS.texinfo 2018-09-10 10:55:52.000000000 +0000 @@ -594,16 +594,21 @@ extension; if you do, the shell will assume that the path @emph{does} exist, and will complain that it cannot find it. -@node Running the Updater -@unnumbered Running the Updater +@node Running the Currency Updater +@unnumbered Running the Currency Updater @node Updating from the Command Line @unnumberedsec Updating from the Command Line If the location of @command{units_cur} is on your @env{PATH}, you can -update the definitions by entering @samp{units_cur} from the command -line; you will need elevated permission if you lack write permission on -the file. +update the currency definitions by entering @samp{units_cur} from the +command line; you will need elevated permission if you lack write +permission on the file. + +Reliable free sources of currency exchange rates have been annoyingly +ephemeral, sometimes causing update attempts to fail. Accordingly, +several different sources are now supported---see the units manual for +details. @node Automatic Updates @unnumberedsec Automatic Updates Binary files /tmp/tmp5EHtQ4/72Ux5uwBEZ/units-2.16/units.pdf and /tmp/tmp5EHtQ4/0mofb4A4hK/units-2.19/units.pdf differ diff -Nru units-2.16/units.texinfo units-2.19/units.texinfo --- units-2.16/units.texinfo 2017-11-01 01:44:27.000000000 +0000 +++ units-2.19/units.texinfo 2019-05-29 00:16:22.000000000 +0000 @@ -5,17 +5,20 @@ @finalout @setchapternewpage off @firstparagraphindent none -@set EDITION 2.14 -@set VERSION 2.16 +@set EDITION 2.16 +@set VERSION 2.18 @c %**end of header +@c for AUTHOR section +@c man program units + @c ifman .\" @copying This manual is for GNU Units (version @value{VERSION}), which performs units conversions and units calculations. Copyright @copyright{} 1996, 1997, 1999, 2000, 2001, 2002, 2004, 2005, 2007, -2011--2017 Free Software Foundation, Inc. +2011--2019 Free Software Foundation, Inc. @quotation Permission is granted to copy, distribute and/or modify this document @@ -41,9 +44,12 @@ @end direntry @c end noman -@c man .TH UNITS 1 "16 October 2017" +@c man .TH UNITS 1 "19 March 2019" @c man .SH NAME @c man units \(em unit conversion and calculation program +@c man .\" hack to prevent very thick fraction bars with gropdf +@c man .\" '-1' makes thickness proportional to type size +@c man .if \n(.g .if t \Z@\D't -1'@ @titlepage @title Units Conversion @subtitle Edition @value{EDITION} for @command{units} Version @value{VERSION} @@ -80,8 +86,10 @@ * Unit Expressions:: Forming compound units. * Nonlinear Conversions:: Nonlinear unit conversions (e.g., temperature). * Unit Lists:: Conversion to sums of units (e.g., feet and inches). +* Using CGS Units:: Using CGS units: Gaussian, ESU, or EMU * Logging Calculations:: Logging conversions and calculations in a file. * Invoking Units:: Command line options. +* Output Styles:: Different ways units can print the output. * Defining Your Own Units:: Adding your own unit definitions * Numeric Output Format:: How to change the output format * Localization:: How to define and use regional unit names. @@ -113,6 +121,10 @@ .SH DESCRIPTION @end ignore @c end ifman +@html + +@end html + The @command{units} program converts quantities expressed in various systems of measurement to their equivalents in other systems of @@ -161,8 +173,8 @@ @chapter Interacting with @command{units} @cindex interactive use -To invoke units for interactive use, type @kbd{units} at your shell -prompt. The program will print something like this: +To invoke @command{units} for interactive use, type @kbd{units} at your +shell prompt. The program will print something like this: @example @group @@ -179,11 +191,10 @@ meters to feet, type @kbd{10 meters}. Next, @command{units} will print @w{@samp{You want:}}. You should type the units you want to convert @emph{to}. To convert to feet, you would type @kbd{feet}. If the -@command{readline} library was compiled in then @key{tab} will +@command{readline} library was compiled in, then @key{tab} will complete unit names. @xref{Readline Support}, for more information -about @command{readline}. To quit the program under Unix, press -@key{Ctrl-C} or @key{Ctrl-D}. Under Windows, press @key{Ctrl-C} or -@key{Ctrl-Z}; with the latter, you may also need to press @key{Enter}. +about @command{readline}. To quit the program type @kbd{quit} or +@kbd{exit} at either prompt. The result will be displayed in two ways. The first line of output, which is marked with a @samp{*} to indicate multiplication, gives the @@ -403,12 +414,22 @@ The output tells you that 2 liters is about 2.1 quarts, or alternatively that a quart is about 0.47 times 2 liters. +@command{units} does not require a space between a numerical value and +the unit, so the previous example can be given as + +@example +units 2liters quarts +@end example + +@noindent +to avoid having to quote the first argument. + If the conversion is successful, then @command{units} will return success (zero) to the calling environment. If you enter non-conformable -units then @command{units} will print a message giving the reduced form of +units, then @command{units} will print a message giving the reduced form of each unit and it will return failure (nonzero) to the calling environment. -When you invoke @command{units} with only one argument, it will print out +When you invoke @command{units} with only one argument, it will print the definition of the specified unit. It will return failure if the unit is not defined and success if the unit is defined. @@ -498,7 +519,7 @@ the @samp{en_GB} locale you will get the British volume measures. If it runs in the @samp{en_US} locale you will get the US volume measures. In other locales the default values are the US -definitions. If you wish to force different definitions then set the +definitions. If you wish to force different definitions, then set the environment variable @env{UNITS_ENGLISH} to either @samp{US} or @samp{GB} to set the desired definitions independent of the locale. @@ -905,12 +926,15 @@ @node Built-in Functions @section Built-in Functions @cindex functions, built in +@cindex built-in functions Several built-in functions are provided: @samp{sin}, @samp{cos}, -@samp{tan}, @samp{ln}, @samp{log}, @samp{log2}, @samp{exp}, @samp{acos}, -@samp{atan} and @samp{asin}. The @samp{sin}, @samp{cos}, and @samp{tan} +@samp{tan}, @samp{ln}, @samp{log}, @samp{exp}, @samp{acos}, +@samp{atan}, @samp{asin}, @samp{cosh}, @samp{sinh}, @samp{tanh}, +@samp{acosh}, @samp{asinh}, and @samp{atanh}. +The @samp{sin}, @samp{cos}, and @samp{tan} functions require either a dimensionless argument or an argument with -dimensions of angle. +dimensions of angle. @example @group @@ -933,6 +957,36 @@ inverse trigonometric functions return arguments with dimensions of angle. +@cindex logs +The @samp{ln} and @samp{log} functions give natural log and log base +10 respectively. To obtain logs for any integer base, enter the +desired base immediately after @samp{log}. For example, to get log +base 2 you would write @samp{log2} and to get log base 47 you could +write @samp{log47}. + +@example +@group +You have: log2(32) +You want: + Definition: 5 +You have: log3(32) +You want: + Definition: 3.1546488 +You have: log4(32) +You want: + Definition: 2.5 +You have: log32(32) +You want: + Definition: 1 +You have: log(32) +You want: + Definition: 1.50515 +You have: log10(32) +You want: + Definition: 1.50515 +@end group +@end example + @cindex roots @cindex square roots If you wish to take roots of units, you may use the @samp{sqrt} or @@ -1038,7 +1092,6 @@ immediately after invocation) generates an error: @set codequoteundirected -@c man .if \n(.g .tr '\(aq @example @group You have: _ @@ -1046,7 +1099,6 @@ No previous result; '_' not set @end group @end example -@c man .if \n(.g .tr '' @clear codequoteundirected @noindent @@ -1077,6 +1129,10 @@ @section Complicated Unit Expressions @cindex unit expressions, complicated +@html + +@end html + @noindent The @command{units} program is especially helpful in ensuring accuracy and dimensional consistency when converting lengthy unit expressions. @@ -1088,15 +1144,24 @@ \Delta P = {8 \over \pi^2} \rho fL { Q^2 \over d^5} $$ @end tex -@ifnottex +@ifinfo @example Delta P = (8/pi^2) rho f L (Q^2 / d^5) @end example -@end ifnottex -@noindent -where @math{ \Delta P} is the pressure drop, @math{\rho} is the mass density, +@end ifinfo +@html +\[ \Delta P = \frac{8}{\pi^2} \rho fL \frac{Q^2}{d^5} \] +@end html +@noindent +@ifinfo +where @w{Delta P} is the pressure drop, rho +@end ifinfo +@ifnotinfo +where @math{ \Delta P} is the pressure drop, @math{\rho} +@end ifnotinfo +is the mass density, @math{f} is the (dimensionless) friction factor, @math{L} is the length of the pipe, @math{Q} is the volumetric flow rate, and @math{d} is the pipe diameter. @@ -1106,13 +1171,16 @@ \Delta P = A_1 \rho fL {Q^2 \over d^5} $$ @end tex -@ifnottex +@html +\[ \Delta P = A_1 \rho fL \frac{Q^2}{d^5} \] +@end html +@ifinfo @example Delta P = A1 rho f L (Q^2 / d^5) @end example -@end ifnottex +@end ifinfo @c end noman @c ----------------------------------- @c nroff--assume neqn is not available @@ -1121,17 +1189,17 @@ @c man For example, one form of the Darcy-Weisbach fluid-flow equation is @c man .RS 5n @c man .PP -@c man Delta \fIP\fP = (8 / pi)^2 (rho \fIfLQ\fP^2) / \fId\fP^5, +@c man Delta \fIP\fP = (8 / pi)^2 (\fIrho\fP \fIfLQ\fP^2) / \fId\fP^5, @c man .RE @c man .PP -@c man where Delta \fIP\fP is the pressure drop, rho is the mass density, +@c man where Delta \fIP\fP is the pressure drop, \fIrho\fP is the mass density, @c man \fIf\fP is the (dimensionless) friction factor, \fIL\fP is the length @c man of the pipe, \fIQ\fP is the volumetric flow rate, and \fId\fP @c man is the pipe diameter. @c man It might be desired to have the equation in the form @c man .RS 5n @c man .PP -@c man Delta \fIP\fP = A1 rho \fIfLQ\fP^2 / \fId\fP^5 +@c man Delta \fIP\fP = A1 \fIrho\fP \fIfLQ\fP^2 / \fId\fP^5 @c man .RE @c man .PP @c man .++ @@ -1252,7 +1320,7 @@ When @samp{-} is used as a unary operator it negates its operand. Regardless of the @command{units} options, if @samp{-} appears after @samp{(} or after -@samp{+} then it will act as a negation operator. So you can always compute 20 +@samp{+}, then it will act as a negation operator. So you can always compute 20 degrees minus 12 minutes by entering @samp{20@tie{}degrees + -12@tie{}arcmin}. You must use this construction when you define new units because you cannot know what options will be in force when your definition is @@ -1840,6 +1908,437 @@ @end group @end example +@node Using CGS Units +@chapter Using CGS Units +@cindex CGS units, using + +@html + +@end html + + +@menu +* Specifying CGS Units:: How to specify the desired CGS units +* CGS Units Systems:: The various CGS units systems +* Conversions Between Systems:: Conversions between units in different systems +* Prompt Prefix:: The prompt prefix shows specified CGS units +@end menu + +The SI---an extension of the MKS (meter--kilogram--second) system---has +largely supplanted the older CGS (centimeter--gram--second) system, but +CGS units are still used in a few specialized fields, especially in +physics where they lead to a more elegant formulation of Maxwell's equations. +Conversions between SI and CGS involving mechanical units are +straightforward, involving powers of 10 (e.g., @w{1 m = 100 cm}). +Conversions involving electromagnetic units are more complicated, and +@command{units} supports three different systems of CGS units: +electrostatic units (ESU), electromagnetic units (EMU), and the +Gaussian system. +The differences between these systems +arise from different choices made for proportionality +constants in electromagnetic equations. +Coulomb's law gives electrostatic force between two +charges separated by a distance +@c noman +@math{r}: +@ifinfo +@display + +F = k_C q_1 q_2 / r^2. + +@end display +@end ifinfo +@html +\[ F = k_{\text{C}} \frac{q_1q^2}{r^2}. \] +@end html +@iftex +@tex + $$ + F = k_{\rm C} { {q_1 q_2} \over {r^2} }. + $$ +@end tex +@end iftex +@c end noman +@c +@c man .EQ +@c man delim $$ +@c man .EN +@c man .if n \fIr\fP: +@c man .if t $r$: +@c man .RS 5n +@c man .PP +@c man .if n \fIF\fP = \fIk\fP_C \fIq\fP_1\ \fIq\fP_2\ /\ \fIr\fP^2. +@c man .if t \{ +@c man .EQ +@c man F = k sub roman C { q sub 1 q sub 2} over r sup 2. +@c man .EN +@c man .\} +@c man .RE +@c man .PP + +@noindent +Ampere's law gives the electromagnetic force per unit length +between two current-carrying conductors separated by a distance +@c noman +@math{r}: +@ifinfo +@display + +F/l = 2 k_A I_1 I_2 / r. + +@end display +@end ifinfo +@html +\[ \frac{F}{l} = 2 k_{\text{A}} \frac{I_1I_2}{r}.\] +@end html +@iftex +@tex + $$ + { F \over l } = 2 k_{\rm A} { {I_1 I_2} \over {r} } . + $$ +@end tex +@end iftex +@c end noman +@c +@c man .if n \fIr\fP: +@c man .if t $r$: +@c man .RS 5n +@c man .PP +@c man .if n \fIF\fP/\fIl\fP = 2 \fIk\fP_A \fII\fP_1\ \fII\fP_2\ /\ \fIr\fP. +@c man .if t \{ +@c man .EQ +@c man F over l = 2 k sub roman A { I sub 1 I sub 2 } over r . +@c man .EN +@c man .\} +@c man .RE +@c man .PP + +@noindent +The two constants, +@c noman +@ifinfo +@math{k_C} and @math{k_A}, +@end ifinfo +@html +\(k_{\text{C}}\) and \(k_{\text{A}}\), +@end html +@iftex +@math{k_{\rm C}} and @math{k_{\rm A}}, +@end iftex +are related by the square of the speed of light: +@ifinfo +k_A = k_C / c^2. +@end ifinfo +@html +\(k_{\text{A}} = k_{\text{C}}/c^2\). +@end html +@iftex +@math{k_{\rm A} = k_{\rm C} / c^{2}}. +@end iftex +@c end noman +@c +@c man .if n \fIk\fP_C and \fIk\fP_A, +@c man .if t $k sub roman C$ and $k sub roman A$, +@c man are related by the square of the speed of light: +@c man .if n \fIk\fP_A\ =\ \fIk\fP_C\ /\ \fIc\fP^2. +@c man .if t $k sub roman A = k sub roman C / c sup 2$. + +In the SI, the constants have dimensions, and an additional base unit, +the ampere, measures electric current. The CGS systems do not define +new base units, but express charge and current as derived units in +terms of mass, length, and time. In the ESU system, the constant for +Coulomb's law is chosen to be unity and dimensionless, which defines +the unit of charge. In the EMU system, the constant for Ampere's law +is chosen to be unity and dimensionless, which defines a unit of +current. The Gaussian system usually uses the ESU units for charge +and current; it chooses another constant so that the units for the +electric and magnetic fields are the same. + +The dimensions of electrical quantities in the various CGS systems are +different from the SI dimensions for the same units; +strictly, conversions between these systems and SI are not possible. +But units in different systems relate to the same physical quantities, +so there is a @emph{correspondence} between these units. +The @command{units} program defines the units so that you can convert +between corresponding units in the various systems. + +@node Specifying CGS Units +@section Specifying CGS Units +@cindex CGS units, specifying +@html + +@end html + +The CGS definitions involve +@c noman +@ifinfo +cm^(1/2) and g^(1/2) +@end ifinfo +@html +\(\text{cm}^{1/2}\) and \(\text{g}^{1/2}\) +@end html +@iftex +@math {{\rm cm}^{1/2}} and @math{{\rm g}^{1/2}}, +@end iftex +@c end noman +@c +@c man .if n cm^(1/2) and g^(1/2), +@c man .if t cm$"" sup {1/2}$ and g$"" sup {1/2}$, +@c man +@c +which is problematic because @command{units} does not normally support +fractional roots of base units. The @option{--units} (@option{-u}) +option allows selection of a CGS unit system and works around this +restriction by introducing base units for the square roots of +length and mass: @samp{sqrt_cm} and @samp{sqrt_g}. The centimeter +then becomes @samp{sqrt_cm^2} and the gram, @samp{sqrt_g^2}. +This allows working from +equations using the units in the CGS system, and +enforcing dimensional conformity within that system. Recognized +arguments to the @option{--units} option are @samp{gauss[ian]}, +@samp{esu}, @samp{emu}, and @samp{si}; the argument is case insensitive. +The default mode for @command{units} is SI units; the only effect of +giving @samp{si} with the @option{--units} option is to prepend +@samp{(SI)} to the @w{@samp{You have:}} prompt. Giving an unrecognized +system generates a warning, and @command{units} uses SI units. + +The changes resulting from the @option{--units} option are actually +controlled by the @env{UNITS_SYSTEM} environment variable. If you +frequently work with one of the supported CGS units systems, you may set +this environment variable rather than giving the @option{--units} option +at each invocation. As usual, an option given on the command line +overrides the setting of the environment variable. For example, if you would +normally work with Gaussian units but might occasionally work with +SI, you could set @env{UNITS_SYSTEM} to @samp{gaussian} and specify +SI with the @option{--units} option. +Unlike the argument to the @option{--units} option, the value of +@env{UNITS_SYSTEM} @emph{is} case sensitive, so setting a value of +@samp{EMU} will have no effect other than to give an error message and +set SI units. + +The CGS definitions appear as conditional settings in the standard +units data file, which you can consult for more information on how +these units are defined, or on how to define an alternate units system. + +@node CGS Units Systems +@section CGS Units Systems +@cindex CGS Units Systems +@cindex units systems, CGS +@html + +@end html + +The ESU system derives the electromagnetic units from its unit of +charge, the statcoulomb, +which is defined from +Coulomb's law. The statcoulomb equals +@c noman +@ifinfo +@w{dyne^(1/2) cm} or @w{cm^(3/2) g^(1/2) s^(-1)}. +@end ifinfo +@html +\(\text{dyne}^{1/2}\text{cm}\) or +\(\text{cm}^{3/2}\text{g}^{1/2}\text{s}^{-1}\). +@end html +@c +@iftex +@math{{\rm dyne}^{1/2}\,{\rm cm}} or @math{{\rm cm}^{3/2}\,{\rm g}^{1/2}\,{\rm s}^{-1}}. +@end iftex +@c end noman +@c +@c man .if n dyne^(1/2)\ cm, or cm^(3/2)\ g^(1/2)\ s^(\(mi1). +@c man .if t $roman dyne sup {1/2} ^ roman cm$, +@c man .if t or $roman cm sup {3/2} ^ roman g sup {1/2} ^ roman s sup {-1}$. +The unit of current, the statampere, is @w{statcoulomb sec}, analogous to +the relationship in SI. Other electrical units are then derived in a +manner similar to that for SI units; the units use the SI names prefixed +by @samp{stat-}, e.g., @samp{statvolt} or @samp{statV}. The prefix +@samp{st-} is also recognized (e.g., @samp{stV}). + +The EMU system derives the electromagnetic units from its unit of current, +the abampere, which is defined in terms of Ampere's law. The abampere +is equal to +@c noman +@ifinfo +dyne^(1/2) or @w{cm^(1/2) g^(1/2) s^(-1)}. +@end ifinfo +@html +\(\text{dyne}^{1/2}\) or \(\text{cm}^{1/2}\text{g}^{1/2}\text{s}^{-1}\). +@end html +@c +@iftex +@math{{\rm dyne}^{1/2}}, or @math{{\rm cm}^{1/2}\,{\rm g}^{1/2}\,{\rm s}^{-1}}. +@end iftex +@c end noman +@c +@c man .if n dyne^(1/2), or cm^(1/2)\ g^(1/2)\ s^(\(mi1). +@c man .if t $roman dyne sup {1/2}$, +@c man .if t or $roman cm sup {1/2} ^ roman g sup {1/2} ^ roman s sup{-1}$. +@c man .EQ +@c man delim off +@c man .EN +The unit of charge, the abcoulomb, is +@w{abampere sec}, again analogous to the SI relationship. +Other electrical units are then derived in a +manner similar to that for SI units; the units use the SI names prefixed +by @samp{ab-}, e.g., @samp{abvolt} or @samp{abV}. The magnetic field +units include the gauss, the oersted and the maxwell. + +The Gaussian units system, which was also known as the Symmetric +System, +uses the same charge and current units as the ESU system (e.g., +@samp{statC}, @samp{statA}); it differs by defining the magnetic field +so that it has the same units as the electric field. The resulting +magnetic field units are the same ones used in the EMU system: the +gauss, the oersted and the maxwell. + +@node Conversions Between Systems +@section Conversions Between Different Systems + +The CGS systems define units that measure the same thing but may have +conflicting dimensions. Furthermore, the dimensions of the +electromagnetic CGS units are never compatible with SI. +But if you measure charge in two different systems you have measured the +same physical thing, so there is a @emph{correspondence} between the +units in the different systems, and @command{units} supports conversions +between corresponding units. When running with SI, @command{units} +defines all of the CGS units in terms of SI. When you select a CGS +system, @command{units} defines the SI units and the other CGS system +units in terms of the system you have selected. + +@example +@group +(Gaussian) You have: statA + You want: abA + * 3.335641e-11 + / 2.9979246e+10 +(Gaussian) You have: abA + You want: sqrt(dyne) +conformability error + 2.9979246e+10 sqrt_cm^3 sqrt_g / s^2 + 1 sqrt_cm sqrt_g / s +@end group +@end example + +@noindent +In the above example, @command{units} converts between the current +units statA and abA even though the abA, from the EMU system, has +incompatible dimensions. This works because in Gaussian mode, the abA +is defined in terms of the statA, so it does not have the correct +definition for EMU; consequently, you cannot convert the abA to its EMU +definition. + +One challenge of conversion is that because +the CGS system has fewer base units, quantities that have different +dimensions in SI may have the same dimension in a CGS system. And +yet, they may not have the same conversion factor. For example, the +unit for the @math{E} field and @math{B} fields are the same in the +Gaussian system, but the conversion factors to SI are quite +different. This means that correct conversion is only possible if you +keep track of what quantity is being measured. You cannot convert +statV/cm to SI without indicating which type of field the unit +measures. To aid in dimensional analysis, @command{units} defines +various dimension units such as LENGTH, TIME, and CHARGE to be the +appropriate dimension in SI. The +electromagnetic dimensions such as B_FIELD or E_FIELD may be useful +aids both for conversion and dimensional analysis in CGS. You +can convert them to or from CGS in order to perform SI conversions +that in some cases will not work directly due to dimensional incompatibilities. +This example shows how the Gaussian system uses the same units for all +of the fields, but they all have different conversion factors with +SI. + +@example +@group +(Gaussian) You have: statV/cm + You want: E_FIELD + * 29979.246 + / 3.335641e-05 +@end group +@group +(Gaussian) You have: statV/cm + You want: B_FIELD + * 0.0001 + / 10000 +@end group +@group +(Gaussian) You have: statV/cm + You want: H_FIELD + * 79.577472 + / 0.012566371 +@end group +@group +(Gaussian) You have: statV/cm + You want: D_FIELD + * 2.6544187e-07 + / 3767303.1 +@end group +@end example + +@noindent +The next example shows that the oersted cannot be converted directly +to the SI unit of magnetic field, A/m, because the dimensions +conflict. We cannot redefine the ampere to make this work because +then it would not convert with the statampere. But you can still do +this conversion as shown below. + +@example +@group +(Gaussian) You have: oersted + You want: A/m +conformability error + 1 sqrt_g / s sqrt_cm + 29979246 sqrt_cm sqrt_g / s^2 +(Gaussian) You have: oersted + You want: H_FIELD + * 79.577472 + / 0.012566371 +@end group +@end example + + +@node Prompt Prefix +@section Prompt Prefix +@cindex prompt prefix with CGS units +@cindex CGS units, prompt prefix + +If a unit system is specified with the @option{--units} option, the +selected system's name is prepended to the @w{@samp{You have:}} prompt +as a reminder, e.g., + +@example +@group +(Gaussian) You have: stC + You want: + Definition: statcoulomb = sqrt(dyne) cm = 1 sqrt_cm^3 sqrt_g / s +@end group +@end example + +@noindent +You can suppressed the prefix by including a line + +@example +!prompt +@end example + +@noindent +with no argument in a site or personal units data file. The prompt can +be conditionally suppressed by including such a line within +@samp{!var} ... @samp{!endvar} constructs, e.g., + +@example +@group +!var UNITS_SYSTEM gaussian gauss +!prompt +!endvar +@end group +@end example + +@noindent +This might be appropriate if you normally use Gaussian units and find +the prefix distracting but want to be reminded when you have selected a +different CGS system. + @node Logging Calculations @chapter Logging Calculations @cindex logging calculations @@ -1955,7 +2454,9 @@ display the definition of that unit and exit. Units specified on the command line may need to be quoted to protect them from shell interpretation and to group -them into two arguments. @xref{Command Line Use}. +them into two arguments. Note also that the @option{--quiet} option +is enabled by default if you specify @var{from-unit} on the command line. +@xref{Command Line Use}. The default behavior of @command{units} can be changed by various options given on the command line. In most cases, the options may be @@ -2145,24 +2646,6 @@ the usual rules of algebra: the precedence of @samp{*} is the same as the precedence of @samp{/}, so that @samp{1/2*3} will equal @samp{3/2}. -@item --compact -@opindex --compact @r{(option for} @command{units}@r{)} -Give compact output featuring only the conversion factor. This turns -off the @option{--verbose} option. - -@item -q -@itemx --quiet -@itemx --silent -@opindex -q @r{(option for} @command{units}@r{)} -@opindex --quiet @r{(option for} @command{units}@r{)} -@opindex --silent @r{(option for} @command{units}@r{)} -Suppress prompting of the user for units and the display of statistics -about the number of units loaded. - -@item -n -@itemx --nolists -Disable conversion to unit lists. - @item -r @itemx --round When converting to a combination of units given by a unit list, round @@ -2187,35 +2670,6 @@ will always be shown as @samp{2 * 3|4@tie{}cup} whether or not the @option{--show-factor} option is given. -@item -s -@itemx --strict -@opindex -s @r{(option for} @command{units}@r{)} -@opindex --strict @r{(option for} @command{units}@r{)} -Suppress conversion of units to their reciprocal units. For -example, @command{units} will normally convert hertz to seconds -because these units are reciprocals of each other. The strict option -requires that units be strictly conformable to perform a conversion, and -will give an error if you attempt to convert hertz to seconds. - -@item -1 -@itemx --one-line -@opindex -1 @r{(option for} @command{units}@r{)} -@opindex --one-line @r{(option for} @command{units}@r{)} -Give only one line of output (the forward conversion). Do not print -the reverse conversion. If a reciprocal conversion is -performed then @command{units} will still print the ``reciprocal -conversion'' line. - -@item -t -@itemx --terse -@opindex -t @r{(option for} @command{units}@r{)} -@opindex --terse @r{(option for} @command{units}@r{)} -Give terse output when converting units. This option can be used when -calling @command{units} from another program so that the output is easy to -parse. This option has the combined -effect of these options: @option{--strict} @option{--quiet} @option{--one-line} -@option{--compact}. When combined with @option{--version} it produces -a display showing only the program name and version number. @item -v @itemx --verbose @@ -2267,9 +2721,14 @@ Print the location of the default units data file and exit; if the file cannot be found, print ``Units data file not found''. +@item -u (gauss[ian]|esu|emu) +@itemx --units (gauss[ian]|esu|emu) +@opindex -u @r{(option for} @command{units}@r{)} +@opindex --units @r{(option for} @command{units}@r{)} +Specify a CGS units system: Gaussian, ESU, or EMU. + @item -l @var{locale} @itemx --locale @var{locale} -Print the information given with the @option{--version} option, show the @opindex --locale @r{(option for} @command{units}@r{)} @opindex -l @r{(option for} @command{units}@r{)} Force a specified locale such as @samp{en_GB} to get British @@ -2277,8 +2736,202 @@ system settings or environment variables. @xref{Locale}, for a description of locale format. +@item -n +@itemx --nolists +Disable conversion to unit lists. + +@item -s +@itemx --strict +@opindex -s @r{(option for} @command{units}@r{)} +@opindex --strict @r{(option for} @command{units}@r{)} +Suppress conversion of units to their reciprocal units. For +example, @command{units} will normally convert hertz to seconds +because these units are reciprocals of each other. The strict option +requires that units be strictly conformable to perform a conversion, and +will give an error if you attempt to convert hertz to seconds. + +@item -1 +@itemx --one-line +@opindex -1 @r{(option for} @command{units}@r{)} +@opindex --one-line @r{(option for} @command{units}@r{)} +Give only one line of output (the forward conversion); do not print +the reverse conversion. If a reciprocal conversion is +performed, then @command{units} will still print the ``reciprocal +conversion'' line. + +@item -t +@itemx --terse +@opindex -t @r{(option for} @command{units}@r{)} +@opindex --terse @r{(option for} @command{units}@r{)} +Print only a single conversion factor. This option can be used when +calling @command{units} from another program so that the output is easy to +parse. This option has the combined +effect of these options: @option{--strict} @option{--quiet} @option{--one-line} +@option{--compact}. When combined with @option{--version} it produces +a display showing only the program name and version number. + +@item --compact +@opindex --compact @r{(option for} @command{units}@r{)} +Give compact output featuring only the conversion factor; the +multiplication and division signs are not shown, and there is no leading +whitespace. If you convert to a unit list, then the output is a +semicolon separated list of factors. +This turns off the @option{--verbose} option. + +@item -q +@itemx --quiet +@itemx --silent +@opindex -q @r{(option for} @command{units}@r{)} +@opindex --quiet @r{(option for} @command{units}@r{)} +@opindex --silent @r{(option for} @command{units}@r{)} +Suppress the display of statistics about the number of units loaded, +any messages printed by the units database, +and the prompting of the user for units. This option does not +affect how @command{units} displays the results. This option is +turned on by default if you invoke @command{units} with a unit +expression on the command line. + @end table +@node Output Styles +@chapter Output Styles +The output can be tweaked in various ways using command line options. +With no options, the output looks like this + +@example +@group +$ units +Currency exchange rates from FloatRates (USD base) on 2019-02-20 +3070 units, 109 prefixes, 109 nonlinear units + +You have: 23ft +You want: m + * 7.0104 + / 0.14264521 +You have: m +You want: ft;in + 3 ft + 3.3700787 in +@end group +@end example + +@noindent +This is arguably a bit cryptic; the @option{--verbose} +option makes clear what the output means: + +@example +@group +$ units --verbose +Currency exchange rates from FloatRates (USD base) on 2019-02-20 +3070 units, 109 prefixes, 109 nonlinear units + +You have: 23 ft +You want: m + 23 ft = 7.0104 m + 23 ft = (1 / 0.14264521) m +You have: meter +You want: ft;in + meter = 3 ft + 3.3700787 in +@end group +@end example + +@noindent +The @option{--quiet} option suppresses the clutter displayed when +@command{units} starts, as well as the prompts to the user. +This option is enabled by default when you +give units on the command line. + +@example +@group +$ units --quiet +23 ft +m + * 7.0104 + / 0.14264521 + +$ units 23ft m + * 7.0104 + / 0.14264521 +@end group +@end example + +@noindent +The remaining style options allow you to display only numerical values +without the tab or the multiplication and division signs, or to display just a +single line showing the forward conversion: + +@set codequoteundirected +@example +@group +$ units --compact 23ft m +7.0104 +0.14264521 + +$ units --compact m 'ft;in' +3;3.3700787 + +$ units --one-line 23ft m + * 7.0104 + +$ units --one-line 23ft 1/m + reciprocal conversion + * 0.14264521 + +$ units --one-line 23ft kg +conformability error + 7.0104 m + 1 kg +@end group +@end example + +@noindent +Note that when converting to a unit list, the @option{--compact} +option displays a semicolon separated list of results. Also be aware +that the +@option{one-line} option doesn't live up to its name if you +execute a reciprocal conversion or if you get a conformability error. +The former case can be prevented using the @option{--strict} option, +which suppresses reciprocal conversions. +Similarly you can suppress unit list conversion using +@option{--nolists}. +It is impossible to prevent +the three line error output. + +@example +@group +$ units --compact --nolists m 'ft;in' +Error in 'ft;in': Parse error + +$ units --one-line --strict 23ft 1/m +@end group +@end example + +@noindent +The various style options can be combined appropriately. The ultimate +combination is the @option{--terse} option, which combines +@option{--strict}, @option{--quiet}, @option{--one-line}, +and @option{--compact} to produce the minimal output, +just a single number for regular conversions and a semicolon +separated list for conversion to unit lists. This will likely be the +best choice for programs that want to call @command{units} and then +process its result. + +@example +@group +$ units --terse 23ft m +7.0104 + +$ units --terse m 'ft;in' +3;3.3700787 + +$ units --terse 23ft 1/m +conformability error +7.0104 m +1 / m +@end group +@end example +@clear codequoteundirected + + @node Defining Your Own Units @chapter Adding Your Own Definitions @@ -2376,7 +3029,7 @@ the file's name. The @samp{!} must be the first character on the line. The file will be sought in the same directory as the parent file unless you give a full path. The name of the file to be -included cannot contain the comment character @samp{#}. +included cannot contain spaces or the comment character @samp{#}. @cindex include files Unit names must not contain any of the operator characters @samp{+}, @@ -2422,7 +3075,8 @@ @cindex parentheses If you define any units that contain -@samp{+} characters, carefully check them because the @option{-c} option +@samp{+} characters in their definitions, +carefully check them because the @option{-c} option will not catch non-conformable sums. Be careful with the @samp{-} operator as well. When used as a binary operator, the @samp{-} character can perform addition or multiplication @@ -2434,6 +3088,13 @@ consistent behavior. To compute the difference of @samp{foo} and @samp{bar} write @samp{foo+(-bar)} or even @samp{foo+-bar}. +You may wish to intentionally redefine a unit. When you do this, and +use the @option{-c} option, @command{units} displays a warning message +about the redefinition. You can suppress these warnings by redefining +a unit using a @samp{+} at the beginning of the unit name. Do not +include any white space between the @samp{+} and the redefined unit +name. + Here is an example of a short data file that defines some basic units: @@ -2445,9 +3106,10 @@ micro- 1e-6 # Define a prefix minute 60 sec # A minute is 60 seconds hour 60 min # An hour is 60 minutes -inch 0.0254 m # Inch defined in terms of meters +inch 72 m # Inch defined incorrectly terms of meters ft 12 inches # The foot defined in terms of inches mile 5280 ft # And the mile ++inch 0.0254 m # Correct redefinition, warning suppressed @end group @end example @@ -2455,7 +3117,7 @@ @noindent A unit that ends with a @samp{-} character is a prefix. If a prefix definition contains any @samp{/} characters, be sure they are protected -by parentheses. If you define @samp{half- 1/2} then @samp{halfmeter} +by parentheses. If you define @samp{half- 1/2}, then @samp{halfmeter} would be equivalent to @samp{1 / (2@tie{}meter)}. @node Defining Nonlinear Units @@ -2626,7 +3288,7 @@ parameter value of 900@tie{}mm for comparison. Without units, numerical values other than zero or plus or minus infinity for domain or range endpoints are meaningless, and accordingly they are not allowed. If -you give other values without units then the definition will be ignored +you give other values without units, then the definition will be ignored and you will get an error message. Although the units, domain, and range specifications are optional, it's @@ -3288,7 +3950,7 @@ environment variable does @emph{not} equal any of the list values. The inch has long been a customary measure of length in many places. -The word comes from the latin @emph{uncia} meaning ``one twelfth,'' +The word comes from the Latin @emph{uncia} meaning ``one twelfth,'' referring to its relationship with the foot. By the 20th century, the inch was officially defined in English-speaking countries relative to the yard, but until 1959, the yard differed slightly among those @@ -3336,7 +3998,7 @@ When @command{units} reads the above definitions it will check the environment variable @env{INCH_UNIT} and load only the definitions for the appropriate section. If @env{INCH_UNIT} is unset or is not set to -one of the four values listed then @command{units} will run the last +one of the four values listed, then @command{units} will run the last block. In this case that block uses the @samp{!message} command to display a warning message. Alternatively that block could set default values. @@ -3346,7 +4008,7 @@ environment variable @emph{only if it is not already set}; these settings are only for the current @command{units} invocation and do not persist. So if the example above were preceded by -@samp{!set INCH_UNIT france} then this would make @samp{france} the +@samp{!set INCH_UNIT france}, then this would make @samp{france} the default value for @env{INCH_UNIT}. If the user had set the variable in the environment before invoking @command{units}, then @command{units} would use the user's value. @@ -3381,7 +4043,7 @@ @env{INCH_UNIT} was not set by one of the other commands or by the user. -If the variable given after @samp{!var} or @samp{!varnot} is undefined +If the variable given after @samp{!var} or @samp{!varnot} is undefined, then @command{units} prints an error message and ignores the definitions that follow. Use @samp{!set} to create defaults to prevent this situation from arising. The @option{-c} @@ -3465,6 +4127,13 @@ @env{UNITSFILE} environment variable, and that location does not also contain the locale map file. +@item UNITS_SYSTEM +@cindex UNITS_SYSTEM environment variable +@cindex environment variable, UNITS_SYSTEM +This environment variable is used in the standard data file to select +CGS measurement systems. Currently supported systems are @samp{esu}, +@samp{emu}, @samp{gauss[ian]}, and @samp{si}. The default is @samp{si}. + @end table @node Data Files @@ -3482,7 +4151,8 @@ On Unix-like systems, the data files are typically located in @file{/usr/share/units} if @command{units} is provided with the operating system, or in @file{/usr/local/share/units} if @command{units} -is compiled from the source distribution. +is compiled from the source distribution. Note that the currency file +@file{currency.units} is a symbolic link to another location. On systems running Microsoft Windows, the files may be in the same locations if Unix-like commands are available, a Unix-like file @@ -3524,31 +4194,35 @@ U+007F); definitions using non-ASCII characters appear in blocks beginning with @samp{!utf8} and ending with @samp{!endutf8}. -When @command{units} starts, it checks the locale to determine the -character set. If @command{units} is compiled with Unicode support and -definitions; otherwise these definitions are ignored. When Unicode -support is active, @command{units} will check every line of all of the -units data files for invalid or non-printing UTF-8 sequences; if such -sequences occur, @command{units} ignores the entire line. In addition -to checking validity, @command{units} determines the display width of -non-ASCII characters to ensure proper positioning of the pointer in some -error messages and to align columns for the @samp{search} and @samp{?} -commands. +The non-ASCII definitions are loaded only if the platform and the locale +support @w{UTF-8}. Platform support is determined when @command{units} +is compiled; the locale is checked at every invocation of +@command{units}. To see if your version of @command{units} includes +Unicode support, invoke the program with the @option{--version} option. + +When Unicode support is available, @command{units} checks every line +within UTF-8 blocks in all of the units data files for invalid or +non-printing UTF-8 sequences; if such sequences occur, @command{units} +ignores the entire line. In addition to checking validity, +@command{units} determines the display width of non-ASCII characters to +ensure proper positioning of the pointer in some error messages and to +align columns for the @samp{search} and @samp{?} commands. + +As of early 2019, Microsoft Windows provides limited support for UTF-8 +in console applications, and accordingly, @command{units} does not +support Unicode on Windows. The UTF-16 and UTF-32 encodings are not +supported on any platforms. + +If Unicode support is available and definitions that contain non-ASCII +UTF-8 characters are added to a units data file, those definitions +should be enclosed within @samp{!utf8} @dots{} @samp{!endutf8} to ensure +that they are only loaded when Unicode support is available. As usual, +the @samp{!} must appear as the first character on the line. As +discussed in @ref{Units Data Files}, it's usually best to put such +definitions in supplemental data files linked by an @samp{!include} +command or in a personal units data file. -At present, @command{units} does not support Unicode under Microsoft -Windows. The UTF-16 and UTF-32 encodings are not supported on any -systems. - -If definitions that contain non-ASCII characters are added to a units -data file, those definitions should be enclosed within @samp{!utf8} -@dots{} @samp{!endutf8} to ensure that they are only loaded when -Unicode support is available. As usual, the @samp{!} must appear as -the first character on the line. As discussed in -@ref{Units Data Files}, it's usually best to put such definitions in -supplemental data files linked by an @samp{!include} command or in a -personal units data file. - -When Unicode support is not active, @command{units} makes no assumptions +When Unicode support is not available, @command{units} makes no assumptions about character encoding, except that characters in the range 00--7F hexadecimal correspond to ASCII encoding. Non-ASCII characters are simply sequences of bytes, and have no special meanings; for definitions @@ -3556,12 +4230,13 @@ with this assumption. For example, if you wish to use non-ASCII characters in definitions when running @command{units} under Windows, you can use a character set such as Windows ``ANSI'' (code page 1252 in -the US and Western Europe). You can even use UTF-8, though some -messages may be improperly aligned, and @command{units} will not detect -invalid UTF-8 sequences. If you use UTF-8 encoding when Unicode support -is not active, you should place any definitions with non-ASCII -characters @emph{outside} @samp{!utf8} @dots{} @samp{!endutf8} -blocks---otherwise, they will be ignored. +the US and Western Europe); if this is done, the console code page must +be set to the same encoding for the characters to display properly. +You can even use UTF-8, though some messages may be improperly aligned, +and @command{units} will not detect invalid UTF-8 sequences. If you use +UTF-8 encoding when Unicode support is not available, you should place any +definitions with non-ASCII characters @emph{outside} @samp{!utf8} +@dots{} @samp{!endutf8} blocks---otherwise, they will be ignored. Typeset material other than code examples usually uses the Unicode minus (U+2212) rather than the ASCII hyphen-minus operator (U+002D) used in @@ -3591,7 +4266,7 @@ @cindex unit completion using @samp{?} (@command{readline} only) @cindex completion, unit, using @samp{?} (@command{readline} only) If you type a few characters and then hit @key{ESC} followed by -@kbd{?} then @command{units} will display a list of all the units that +@kbd{?}, then @command{units} will display a list of all the units that start with the characters typed. For example, if you type @kbd{metr} and then request completion, you will see something like this: @cindex unit name completion @@ -3607,7 +4282,7 @@ @end example @noindent -If there is a unique way to complete a unitname, you can hit the @key{TAB} key +If there is a unique way to complete a unit name, you can hit the @key{TAB} key and @command{units} will provide the rest of the unit name. If @command{units} beeps, it means that there is no unique completion. Pressing the @key{TAB} key a second time will print the list of all completions. @@ -3630,23 +4305,123 @@ @cindex currency, updating @cindex exchange rates, updating -The units program includes currency exchange rates and prices for some -precious metals in the database. Of course, these values change over -time, sometimes very rapidly, and @command{units} cannot provide real -time values. To update the exchange rates run the -@command{units_cur}, which rewrites the files containing the currency -rates, typically @file{/usr/share/units/currency.units}. This program -requires @command{python}, and must -be run with suitable permissions to write the file. To keep the rates -updated automatically, run it using a cron job on a Unix-like system, or -a similar scheduling program on a different system. Currency exchange -rates are taken from Yahoo (@uref{http://finance.yahoo.com}) and -precious metals pricing from Packetizer (@uref{www.packetizer.com}). -These sites update once per day, so there is no benefit in running the -update script more often than daily. You can run @command{units_cur} -with a filename specified on the command line and it will write the data -to that file. If you give @samp{-} for the file it will write to -standard output. +@c man .na +The units program database includes currency exchange rates and prices +for some precious metals. Of course, these values change over time, +sometimes very rapidly, and @command{units} cannot provide real-time +values. To update the exchange rates, run @command{units_cur}, which +rewrites the file containing the currency rates, typically +@file{/var/lib/@/units/@/currency.units} or +@file{/usr/local/@/com/@/units/@/currency.units} +on a Unix-like system or +@file{@w{C:\Program Files (x86)}\@/GNU\@/units\@/definitions.units} on a Windows +system. +@c man .ad b + +This program requires Python (@uref{https://www.python.org}); either +version 2 or 3 will work. The program must be run with suitable +permissions to write the file. To keep the rates updated automatically, +run it using a cron job on a Unix-like system, or a similar scheduling +program on a different system. + +Reliable free sources of currency exchange rates have been annoyingly +ephemeral. The program currently supports several sources: + +@itemize @bullet + +@item +FloatRates (@uref{https://www/floatrates.com}). +The US dollar (@samp{USD}) is the default base currency. You can +change the base currency with the +@option{-b} option described below. Allowable base currencies are listed on +the FloatRates website. Exchange rates update daily. + +@item +The European Central Bank (@uref{https://www.ecb.europa.eu}). +The base currency is always the euro (@samp{EUR}). Exchange rates +update daily. This source offers a more limited list of currencies +than the others. + +@item +Fixer (@uref{https://fixer.io}). +Registration for a free API key is required. With a free API key, base +currency is the euro; exchange rates are updated hourly, the +service has a limit of 1,000 API calls per month, and SSL encryption +(https protocol) is not available. Most of these restrictions are +eliminated or reduced with paid plans. + +@item +open exchange rates (@uref{https://openexchangerates.org}). +Registration for a free API key is required. With a free API key, the +base currency is the US dollar; exchange rates are updated hourly, and +there is a limit of 1,000 API calls per month. Most of these +restrictions are eliminated or reduced with paid plans. + +@end itemize + +@noindent +The default source is FloatRates; you can select a different one using +@option{-s} option described below. + +Precious metals pricing is obtained from Packetizer +(@uref{www.packetizer.com}). This site updates once per day. + +You invoke @command{units_cur} like this: + +@example +units_cur [@var{options}] [@var{outfile}] +@end example + +@noindent +By default, the output is written to the default currency file described +above; this is usually what you want, because this is where +@command{units} looks for the file. If you wish, you can specify a +different filename on the command line and @command{units_cur} will +write the data to that file. If you give @samp{-} for the file it will +write to standard output. + +@noindent +The following options are available: + +@table @env +@item -h +@itemx --help +Print a summary of the options for @command{units_cur}. + +@item -V +@itemx --version +Print the @command{units_cur} version number. + +@item -v +@itemx --verbose +Give slightly more verbose output when attempting to update currency +exchange rates. + +@item -s @var{source} +@itemx --source @var{source} +Specify the source for currency exchange rates; currently supported +values are @samp{floatrates} (for FloatRates), @samp{eubank} (for the +European Central Bank), @samp{fixer} (for Fixer), and +@samp{openexchangerates} (for open exchange rates); the last two require +an API key to be given with the @option{-k} option. + +@item -b @var{base} +@itemx --base @var{base} +Set the base currency (when allowed by the site providing the data). +@var{base} should be a 3-letter ISO currency code, e.g., @samp{USD}. +The specified currency will be the primitive currency unit used by +@command{units}. You may find it convenient to specify your local +currency. Conversions may be more accurate and you will be able to +convert to your currency by simply hitting @key{Enter} at the +@w{@samp{You want:}} prompt. This option is ignored if the source +does not allow specifying the base currency. (Currently only +floatrates supports this option.) + +@item -k @var{key} +@itemx --key @var{key} +Set the API key to @var{key} for sources that require it. + +@end table @node Database Syntax @chapter Database Command Syntax @@ -3689,7 +4464,13 @@ @item !message @var{text} Display @var{text} when the database is read unless the quiet -option (@option{-q}) is enabled. +option (@option{-q}) is enabled. If you omit @var{text}, then units +will display a blank line. Messages will also appear in the log +file. + +@item !prompt @var{text} +Prefix the @w{@samp{You have:}} prompt with the specified text. If +you omit @var{text}, then any existing prefix is canceled. @item !set @var{variable} @var{value} Sets the environment variable, @var{variable}, to the specified @@ -3731,5 +4512,3 @@ @c man @DATAFILE@ \(em the standard units data file @c man .SH AUTHOR - - diff -Nru units-2.16/units.txt units-2.19/units.txt --- units-2.16/units.txt 2017-11-01 02:16:28.000000000 +0000 +++ units-2.19/units.txt 2019-05-29 00:32:32.000000000 +0000 @@ -41,8 +41,8 @@ available options. INTERACTING WITH UNITS - To invoke units for interactive use, type 'units' at your shell prompt. - The program will print something like this: + To invoke 'units' for interactive use, type 'units' at your shell + prompt. The program will print something like this: Currency exchange rates from www.timegenie.com on 2014-03-05 2860 units, 109 prefixes, 85 nonlinear units @@ -53,30 +53,29 @@ converting from. For example, if you want to convert ten meters to feet, type '10 meters'. Next, 'units' will print 'You want:'. You should type the units you want to convert to. To convert to feet, you - would type 'feet'. If the 'readline' library was compiled in then tab + would type 'feet'. If the 'readline' library was compiled in, then tab will complete unit names. See Readline Support for more information - about 'readline'. To quit the program under Unix, press Ctrl-C or - Ctrl-D. Under Windows, press Ctrl-C or Ctrl-Z; with the latter, you may - also need to press Enter. + about 'readline'. To quit the program type 'quit' or 'exit' at either + prompt. - The result will be displayed in two ways. The first line of output, + The result will be displayed in two ways. The first line of output, which is marked with a '*' to indicate multiplication, gives the result of the conversion you have asked for. The second line of output, which - is marked with a '/' to indicate division, gives the inverse of the - conversion factor. If you convert 10 meters to feet, 'units' will + is marked with a '/' to indicate division, gives the inverse of the + conversion factor. If you convert 10 meters to feet, 'units' will print * 32.808399 / 0.03048 which tells you that 10 meters equals about 32.8 feet. The second num- - ber gives the conversion in the opposite direction. In this case, it - tells you that 1 foot is equal to about 0.03 dekameters since the + ber gives the conversion in the opposite direction. In this case, it + tells you that 1 foot is equal to about 0.03 dekameters since the dekameter is 10 meters. It also tells you that 1/32.8 is about 0.03. - The 'units' program prints the inverse because sometimes it is a more - convenient number. In the example above, for example, the inverse - value is an exact conversion: a foot is exactly 0.03048 dekameters. + The 'units' program prints the inverse because sometimes it is a more + convenient number. In the example above, for example, the inverse + value is an exact conversion: a foot is exactly 0.03048 dekameters. But the number given the other direction is inexact. If you convert grains to pounds, you will see the following: @@ -86,9 +85,9 @@ * 0.00014285714 / 7000 - From the second line of the output you can immediately see that a - grain is equal to a seven thousandth of a pound. This is not so obvi- - ous from the first line of the output. If you find the output format + From the second line of the output you can immediately see that a + grain is equal to a seven thousandth of a pound. This is not so obvi- + ous from the first line of the output. If you find the output format confusing, try using the '--verbose' option: You have: grain @@ -96,8 +95,8 @@ grain = 0.00010416667 aeginamina grain = (1 / 9600) aeginamina - If you request a conversion between units that measure reciprocal - dimensions, then 'units' will display the conversion results with an + If you request a conversion between units that measure reciprocal + dimensions, then 'units' will display the conversion results with an extra note indicating that reciprocal conversion has been done: You have: 6 ohms @@ -121,8 +120,8 @@ 1 / 20 mph = 180 sec/mile 1 / 20 mph = (1 / 0.0055555556) sec/mile - If you enter incompatible unit types, the 'units' program will print a - message indicating that the units are not conformable and it will dis- + If you enter incompatible unit types, the 'units' program will print a + message indicating that the units are not conformable and it will dis- play the reduced form for each unit: You have: ergs/hour @@ -138,15 +137,15 @@ You want: Definition: fluxunit = 1e-26 W/m^2 Hz = 1e-26 kg / s^2 - The output from 'units' indicates that the jansky is defined to be - equal to a fluxunit which in turn is defined to be a certain combina- - tion of watts, meters, and hertz. The fully reduced (and in this case + The output from 'units' indicates that the jansky is defined to be + equal to a fluxunit which in turn is defined to be a certain combina- + tion of watts, meters, and hertz. The fully reduced (and in this case somewhat more cryptic) form appears on the far right. - Some named units are treated as dimensionless in some situations. - These units include the radian and steradian. These units will be - treated as equal to 1 in units conversions. Power is equal to torque - times angular velocity. This conversion can only be performed if the + Some named units are treated as dimensionless in some situations. + These units include the radian and steradian. These units will be + treated as equal to 1 in units conversions. Power is equal to torque + times angular velocity. This conversion can only be performed if the radian is dimensionless. You have: (14 ft lbf) (12 radians/sec) @@ -154,8 +153,8 @@ * 227.77742 / 0.0043902509 - It is also possible to compute roots and other non-integer powers of - dimensionless units; this allows computations such as the altitude of + It is also possible to compute roots and other non-integer powers of + dimensionless units; this allows computations such as the altitude of geosynchronous orbit: You have: cuberoot(G earthmass / (circle/siderealday)^2) - earthradius @@ -163,32 +162,32 @@ * 22243.267 / 4.4957425e-05 - Named dimensionless units are not treated as dimensionless in other - contexts. They cannot be used as exponents so for example, + Named dimensionless units are not treated as dimensionless in other + contexts. They cannot be used as exponents so for example, 'meter^radian' is forbidden. - If you want a list of options you can type '?' at the 'You want:' - prompt. The program will display a list of named units that are con- - formable with the unit that you entered at the 'You have:' prompt + If you want a list of options you can type '?' at the 'You want:' + prompt. The program will display a list of named units that are con- + formable with the unit that you entered at the 'You have:' prompt above. Conformable unit combinations will not appear on this list. - Typing 'help' at either prompt displays a short help message. You can - also type 'help' followed by a unit name. This will invoke a pager on - the units data base at the point where that unit is defined. You can + Typing 'help' at either prompt displays a short help message. You can + also type 'help' followed by a unit name. This will invoke a pager on + the units data base at the point where that unit is defined. You can read the definition and comments that may give more details or histori- - cal information about the unit. (You can generally quit out of the + cal information about the unit. (You can generally quit out of the page by pressing 'q'.) - Typing 'search' text will display a list of all of the units whose - names contain text as a substring along with their definitions. This + Typing 'search' text will display a list of all of the units whose + names contain text as a substring along with their definitions. This may help in the case where you aren't sure of the right unit name. USING UNITS NON-INTERACTIVELY - The 'units' program can perform units conversions non-interactively + The 'units' program can perform units conversions non-interactively from the command line. To do this, type the command, type the original - unit expression, and type the new units you want. If a units expres- - sion contains non-alphanumeric characters, you may need to protect it - from interpretation by the shell using single or double quote charac- + unit expression, and type the new units you want. If a units expres- + sion contains non-alphanumeric characters, you may need to protect it + from interpretation by the shell using single or double quote charac- ters. If you type @@ -203,21 +202,29 @@ and then exit. The output tells you that 2 liters is about 2.1 quarts, or alternatively that a quart is about 0.47 times 2 liters. + 'units' does not require a space between a numerical value and the + unit, so the previous example can be given as + + units 2liters quarts + + to avoid having to quote the first argument. + If the conversion is successful, then 'units' will return success - (zero) to the calling environment. If you enter non-conformable units - then 'units' will print a message giving the reduced form of each unit - and it will return failure (nonzero) to the calling environment. - - When you invoke 'units' with only one argument, it will print out the - definition of the specified unit. It will return failure if the unit - is not defined and success if the unit is defined. + (zero) to the calling environment. If you enter non-conformable + units, then 'units' will print a message giving the reduced form of + each unit and it will return failure (nonzero) to the calling environ- + ment. + + When you invoke 'units' with only one argument, it will print the defi- + nition of the specified unit. It will return failure if the unit is + not defined and success if the unit is defined. UNIT DEFINITIONS - The conversion information is read from a units data file that is - called 'definitions.units' and is usually located in the - '/usr/share/units' directory. If you invoke 'units' with the '-V' - option, it will print the location of this file. The default file - includes definitions for all familiar units, abbreviations and metric + The conversion information is read from a units data file that is + called 'definitions.units' and is usually located in the + '/usr/share/units' directory. If you invoke 'units' with the '-V' + option, it will print the location of this file. The default file + includes definitions for all familiar units, abbreviations and metric prefixes. It also includes many obscure or archaic units. Many common spelled-out numbers (e.g., 'seventeen') are recognized. @@ -237,80 +244,80 @@ G Gravitational constant mach speed of sound - The standard data file includes atomic masses for all of the elements + The standard data file includes atomic masses for all of the elements and numerous other constants. Also included are the densities of vari- - ous ingredients used in baking so that '2 cups flour_sifted' can be - converted to 'grams'. This is not an exhaustive list. Consult the - units data file to see the complete list, or to see the definitions + ous ingredients used in baking so that '2 cups flour_sifted' can be + converted to 'grams'. This is not an exhaustive list. Consult the + units data file to see the complete list, or to see the definitions that are used. - The 'pound' is a unit of mass. To get force, multiply by the force - conversion unit 'force' or use the shorthand 'lbf'. (Note that 'g' is - already taken as the standard abbreviation for the gram.) The unit - 'ounce' is also a unit of mass. The fluid ounce is 'fluidounce' or + The 'pound' is a unit of mass. To get force, multiply by the force + conversion unit 'force' or use the shorthand 'lbf'. (Note that 'g' is + already taken as the standard abbreviation for the gram.) The unit + 'ounce' is also a unit of mass. The fluid ounce is 'fluidounce' or 'floz'. When British capacity units differ from their US counterparts, such as the British Imperial gallon, the unit is defined both ways with - 'br' and 'us' prefixes. Your locale settings will determine the value - of the unprefixed unit. Currency is prefixed with its country name: + 'br' and 'us' prefixes. Your locale settings will determine the value + of the unprefixed unit. Currency is prefixed with its country name: 'belgiumfranc', 'britainpound'. - When searching for a unit, if the specified string does not appear - exactly as a unit name, then the 'units' program will try to remove a + When searching for a unit, if the specified string does not appear + exactly as a unit name, then the 'units' program will try to remove a trailing 's', 'es'. Next units will replace a trailing 'ies' with 'y'. - If that fails, 'units' will check for a prefix. The database includes - all of the standard metric prefixes. Only one prefix is permitted per - unit, so 'micromicrofarad' will fail. However, prefixes can appear - alone with no unit following them, so 'micro*microfarad' will work, as + If that fails, 'units' will check for a prefix. The database includes + all of the standard metric prefixes. Only one prefix is permitted per + unit, so 'micromicrofarad' will fail. However, prefixes can appear + alone with no unit following them, so 'micro*microfarad' will work, as will 'micro microfarad'. - To find out which units and prefixes are available, read the standard + To find out which units and prefixes are available, read the standard units data file, which is extensively annotated. English Customary Units - English customary units differ in various ways in different regions. - In Britain a complex system of volume measurements featured different - gallons for different materials such as a wine gallon and ale gallon - that different by twenty percent. This complexity was swept away in + English customary units differ in various ways in different regions. + In Britain a complex system of volume measurements featured different + gallons for different materials such as a wine gallon and ale gallon + that different by twenty percent. This complexity was swept away in 1824 by a reform that created an entirely new gallon, the British Impe- - rial gallon defined as the volume occupied by ten pounds of water. - Meanwhile in the USA the gallon is derived from the 1707 Winchester - wine gallon, which is 231 cubic inches. These gallons differ by about - twenty percent. By default if 'units' runs in the 'en_GB' locale you + rial gallon defined as the volume occupied by ten pounds of water. + Meanwhile in the USA the gallon is derived from the 1707 Winchester + wine gallon, which is 231 cubic inches. These gallons differ by about + twenty percent. By default if 'units' runs in the 'en_GB' locale you will get the British volume measures. If it runs in the 'en_US' locale you will get the US volume measures. In other locales the default val- - ues are the US definitions. If you wish to force different definitions - then set the environment variable 'UNITS_ENGLISH' to either 'US' or - 'GB' to set the desired definitions independent of the locale. + ues are the US definitions. If you wish to force different defini- + tions, then set the environment variable 'UNITS_ENGLISH' to either 'US' + or 'GB' to set the desired definitions independent of the locale. Before 1959, the value of a yard (and other units of measure defined in - terms of it) differed slightly among English-speaking countries. In - 1959, Australia, Canada, New Zealand, the United Kingdom, the United - States, and South Africa adopted the Canadian value of 1 yard = - 0.9144 m (exactly), which was approximately halfway between the values - used by the UK and the US; it had the additional advantage of making - 1 inch = 2.54 cm (exactly). This new standard was termed the Interna- - tional Yard. Australia, Canada, and the UK then defined all customary - lengths in terms of the International Yard (Australia did not define - the furlong or rod); because many US land surveys were in terms of the - pre-1959 units, the US continued to define customary surveyors' units - (furlong, chain, rod, and link) in terms of the previous value for the - foot, which was termed the US survey foot. The US defined a US survey - mile as 5280 US survey feet, and defined a statute mile as a US survey + terms of it) differed slightly among English-speaking countries. In + 1959, Australia, Canada, New Zealand, the United Kingdom, the United + States, and South Africa adopted the Canadian value of 1 yard = + 0.9144 m (exactly), which was approximately halfway between the values + used by the UK and the US; it had the additional advantage of making + 1 inch = 2.54 cm (exactly). This new standard was termed the Interna- + tional Yard. Australia, Canada, and the UK then defined all customary + lengths in terms of the International Yard (Australia did not define + the furlong or rod); because many US land surveys were in terms of the + pre-1959 units, the US continued to define customary surveyors' units + (furlong, chain, rod, and link) in terms of the previous value for the + foot, which was termed the US survey foot. The US defined a US survey + mile as 5280 US survey feet, and defined a statute mile as a US survey mile. The US values for these units differ from the international val- ues by about 2 ppm. - The 'units' program uses the international values for these units; the + The 'units' program uses the international values for these units; the US values can be obtained by using either the 'US' or the 'survey' pre- fix. In either case, the simple familiar relationships among the units - are maintained, e.g., 1 'furlong' = 660 'ft', and 1 'USfurlong' = 660 - 'USft', though the metric equivalents differ slightly between the two - cases. The 'US' prefix or the 'survey' prefix can also be used to - obtain the US survey mile and the value of the US yard prior to 1959, + are maintained, e.g., 1 'furlong' = 660 'ft', and 1 'USfurlong' = 660 + 'USft', though the metric equivalents differ slightly between the two + cases. The 'US' prefix or the 'survey' prefix can also be used to + obtain the US survey mile and the value of the US yard prior to 1959, e.g., 'USmile' or 'surveymile' (but not 'USsurveymile'). To get the US value of the statute mile, use either 'USstatutemile' or 'USmile'. Except for distances that extend over hundreds of miles (such as in the - US State Plane Coordinate System), the differences in the miles are + US State Plane Coordinate System), the differences in the miles are usually insignificant: You have: 100 surveymile - 100 mile @@ -318,26 +325,26 @@ * 12.672025 / 0.078913984 - The pre-1959 UK values for these units can be obtained with the prefix + The pre-1959 UK values for these units can be obtained with the prefix 'UK'. - In the US, the acre is officially defined in terms of the US survey - foot, but 'units' uses a definition based on the international foot. - If you want the official US acre use 'USacre' and similarly use - 'USacrefoot' for the official US version of that unit. The difference + In the US, the acre is officially defined in terms of the US survey + foot, but 'units' uses a definition based on the international foot. + If you want the official US acre use 'USacre' and similarly use + 'USacrefoot' for the official US version of that unit. The difference between these units is about 4 parts per million. UNIT EXPRESSIONS Operators You can enter more complicated units by combining units with operations - such as multiplication, division, powers, addition, subtraction, and - parentheses for grouping. You can use the customary symbols for these - operators when 'units' is invoked with its default options. Addition- - ally, 'units' supports some extensions, including high priority multi- - plication using a space, and a high priority numerical division opera- + such as multiplication, division, powers, addition, subtraction, and + parentheses for grouping. You can use the customary symbols for these + operators when 'units' is invoked with its default options. Addition- + ally, 'units' supports some extensions, including high priority multi- + plication using a space, and a high priority numerical division opera- tor ('|') that can simplify some expressions. - You multiply units using a space or an asterisk ('*'). The next exam- + You multiply units using a space or an asterisk ('*'). The next exam- ple shows both forms: You have: arabicfoot * arabictradepound * force @@ -359,40 +366,40 @@ * 0.00010356166 / 9656.0833 - White space surrounding operators is optional, so the previous example - could have used '(1/2)kg/(kg/meter)'. As a consequence, however, - hyphenated spelled-out numbers (e.g., 'forty-two') cannot be used; + White space surrounding operators is optional, so the previous example + could have used '(1/2)kg/(kg/meter)'. As a consequence, however, + hyphenated spelled-out numbers (e.g., 'forty-two') cannot be used; 'forty-two' is interpreted as '40 - 2'. - Multiplication using a space has a higher precedence than division - using a slash and is evaluated left to right; in effect, the first '/' - character marks the beginning of the denominator of a unit expression. - This makes it simple to enter a quotient with several terms in the - denominator: 'J / mol K'. The '*' and '/' operators have the same - precedence, and are evaluated left to right; if you multiply with '*', - you must group the terms in the denominator with parentheses: + Multiplication using a space has a higher precedence than division + using a slash and is evaluated left to right; in effect, the first '/' + character marks the beginning of the denominator of a unit expression. + This makes it simple to enter a quotient with several terms in the + denominator: 'J / mol K'. The '*' and '/' operators have the same + precedence, and are evaluated left to right; if you multiply with '*', + you must group the terms in the denominator with parentheses: 'J / (mol * K)'. - The higher precedence of the space operator may not always be advanta- + The higher precedence of the space operator may not always be advanta- geous. For example, 'm/s s/day' is equivalent to 'm / s s day' and has - dimensions of length per time cubed. Similarly, '1/2 meter' refers to - a unit of reciprocal length equivalent to 0.5/meter, perhaps not what - you would intend if you entered that expression. The get a half meter - you would need to use parentheses: '(1/2) meter'. The '*' operator is - convenient for multiplying a sequence of quotients. For example, - 'm/s * s/day' is equivalent to 'm/day'. Similarly, you could write + dimensions of length per time cubed. Similarly, '1/2 meter' refers to + a unit of reciprocal length equivalent to 0.5/meter, perhaps not what + you would intend if you entered that expression. The get a half meter + you would need to use parentheses: '(1/2) meter'. The '*' operator is + convenient for multiplying a sequence of quotients. For example, + 'm/s * s/day' is equivalent to 'm/day'. Similarly, you could write '1/2 * meter' to get half a meter. - The 'units' program supports another option for numerical fractions: + The 'units' program supports another option for numerical fractions: you can indicate division of numbers with the vertical bar ('|'), so if - you wanted half a meter you could write '1|2 meter'. You cannot use - the vertical bar to indicate division of non-numerical units (e.g., + you wanted half a meter you could write '1|2 meter'. You cannot use + the vertical bar to indicate division of non-numerical units (e.g., 'm|s' results in an error message). - Powers of units can be specified using the '^' character, as shown in - the following example, or by simple concatenation of a unit and its - exponent: 'cm3' is equivalent to 'cm^3'; if the exponent is more than - one digit, the '^' is required. You can also use '**' as an exponent + Powers of units can be specified using the '^' character, as shown in + the following example, or by simple concatenation of a unit and its + exponent: 'cm3' is equivalent to 'cm^3'; if the exponent is more than + one digit, the '^' is required. You can also use '**' as an exponent operator. You have: cm^3 @@ -400,27 +407,27 @@ * 0.00026417205 / 3785.4118 - Concatenation only works with a single unit name: if you write - '(m/s)2', 'units' will treat it as multiplication by 2. When a unit - includes a prefix, exponent operators apply to the combination, so + Concatenation only works with a single unit name: if you write + '(m/s)2', 'units' will treat it as multiplication by 2. When a unit + includes a prefix, exponent operators apply to the combination, so 'centimeter3' gives cubic centimeters. If you separate the prefix from - the unit with any multiplication operator (e.g., 'centi meter^3'), the - prefix is treated as a separate unit, so the exponent applies only to - the unit without the prefix. The second example is equivalent to - 'centi * (meter^3)', and gives a hundredth of a cubic meter, not a - cubic centimeter. The 'units' program is limited internally to prod- - ucts of 99 units; accordingly, expressions like 'meter^100' or + the unit with any multiplication operator (e.g., 'centi meter^3'), the + prefix is treated as a separate unit, so the exponent applies only to + the unit without the prefix. The second example is equivalent to + 'centi * (meter^3)', and gives a hundredth of a cubic meter, not a + cubic centimeter. The 'units' program is limited internally to prod- + ucts of 99 units; accordingly, expressions like 'meter^100' or 'joule^34' (represented internally as 'kg^34 m^68 / s^68') will fail. - The '|' operator has the highest precedence, so you can write the - square root of two thirds as '2|3^1|2'. The '^' operator has the sec- + The '|' operator has the highest precedence, so you can write the + square root of two thirds as '2|3^1|2'. The '^' operator has the sec- ond highest precedence, and is evaluated right to left, as usual: You have: 5 * 2^3^2 You want: Definition: 2560 - With a dimensionless base unit, any dimensionless exponent is meaning- + With a dimensionless base unit, any dimensionless exponent is meaning- ful (e.g., 'pi^exp(2.371)'). Even though angle is sometimes treated as dimensionless, exponents cannot have dimensions of angle: @@ -428,27 +435,27 @@ ^ Exponent not dimensionless - If the base unit is not dimensionless, the exponent must be a rational - number p/q, and the dimension of the unit must be a power of q, so - 'gallon^2|3' works but 'acre^2|3' fails. An exponent using the slash + If the base unit is not dimensionless, the exponent must be a rational + number p/q, and the dimension of the unit must be a power of q, so + 'gallon^2|3' works but 'acre^2|3' fails. An exponent using the slash ('/') operator (e.g., 'gallon^(2/3)') is also acceptable; the parenthe- - ses are needed because the precedence of '^' is higher than that of - '/'. Since 'units' cannot represent dimensions with exponents greater - than 99, a fully reduced exponent must have q < 100. When raising a - non-dimensionless unit to a power, 'units' attempts to convert a deci- - mal exponent to a rational number with q < 100. If this is not possi- + ses are needed because the precedence of '^' is higher than that of + '/'. Since 'units' cannot represent dimensions with exponents greater + than 99, a fully reduced exponent must have q < 100. When raising a + non-dimensionless unit to a power, 'units' attempts to convert a deci- + mal exponent to a rational number with q < 100. If this is not possi- ble 'units' displays an error message: You have: ft^1.234 Base unit not dimensionless; rational exponent required - A decimal exponent must match its rational representation to machine + A decimal exponent must match its rational representation to machine precision, so 'acre^1.5' works but 'gallon^0.666' does not. Sums and Differences of Units - You may sometimes want to add values of different units that are out- - side the SI. You may also wish to use 'units' as a calculator that - keeps track of units. Sums of conformable units are written with the + You may sometimes want to add values of different units that are out- + side the SI. You may also wish to use 'units' as a calculator that + keeps track of units. Sums of conformable units are written with the '+' character, and differences with the '-' character. You have: 2 hours + 23 minutes + 32 seconds @@ -466,39 +473,39 @@ * 2.5782804 / 0.38785542 - The expressions that are added or subtracted must reduce to identical + The expressions that are added or subtracted must reduce to identical expressions in primitive units, or an error message will be displayed: You have: 12 printerspoint - 4 heredium ^ Illegal sum of non-conformable units - As usual, the precedence for '+' and '-' is lower than that of the + As usual, the precedence for '+' and '-' is lower than that of the other operators. A fractional quantity such as 2 1/2 cups can be given as '(2+1|2) cups'; the parentheses are necessary because multiplication - has higher precedence than addition. If you omit the parentheses, - 'units' attempts to add '2' and '1|2 cups', and you get an error mes- + has higher precedence than addition. If you omit the parentheses, + 'units' attempts to add '2' and '1|2 cups', and you get an error mes- sage: You have: 2+1|2 cups ^ Illegal sum or difference of non-conformable units - The expression could also be correctly written as '(2+1/2) cups'. If - you write '2 1|2 cups' the space is interpreted as multiplication so + The expression could also be correctly written as '(2+1/2) cups'. If + you write '2 1|2 cups' the space is interpreted as multiplication so the result is the same as '1 cup'. The '+' and '-' characters sometimes appears in exponents like '3.43e+8'. This leads to an ambiguity in an expression like '3e+2 yC'. - The unit 'e' is a small unit of charge, so this can be regarded as - equivalent to '(3e+2) yC' or '(3 e)+(2 yC)'. This ambiguity is - resolved by always interpreting '+' and '-' as part of an exponent if + The unit 'e' is a small unit of charge, so this can be regarded as + equivalent to '(3e+2) yC' or '(3 e)+(2 yC)'. This ambiguity is + resolved by always interpreting '+' and '-' as part of an exponent if possible. Numbers as Units For 'units', numbers are just another kind of unit. They can appear as - many times as you like and in any order in a unit expression. For - example, to find the volume of a box that is 2 ft by 3 ft by 12 ft in + many times as you like and in any order in a unit expression. For + example, to find the volume of a box that is 2 ft by 3 ft by 12 ft in steres, you could do the following: You have: 2 ft 3 ft 12 ft @@ -511,15 +518,16 @@ * 13.888889 / 0.072 - And the second example shows how the dollar sign in the units conver- - sion can precede the five. Be careful: 'units' will interpret '$5' + And the second example shows how the dollar sign in the units conver- + sion can precede the five. Be careful: 'units' will interpret '$5' with no space as equivalent to 'dollar^5'. Built-in Functions - Several built-in functions are provided: 'sin', 'cos', 'tan', 'ln', - 'log', 'log2', 'exp', 'acos', 'atan' and 'asin'. The 'sin', 'cos', and - 'tan' functions require either a dimensionless argument or an argument - with dimensions of angle. + Several built-in functions are provided: 'sin', 'cos', 'tan', 'ln', + 'log', 'exp', 'acos', 'atan', 'asin', 'cosh', 'sinh', 'tanh', 'acosh', + 'asinh', and 'atanh'. The 'sin', 'cos', and 'tan' functions require + either a dimensionless argument or an argument with dimensions of + angle. You have: sin(30 degrees) You want: @@ -537,9 +545,33 @@ inverse trigonometric functions return arguments with dimensions of angle. - If you wish to take roots of units, you may use the 'sqrt' or - 'cuberoot' functions. These functions require that the argument have - the appropriate root. You can obtain higher roots by using fractional + The 'ln' and 'log' functions give natural log and log base 10 respec- + tively. To obtain logs for any integer base, enter the desired base + immediately after 'log'. For example, to get log base 2 you would + write 'log2' and to get log base 47 you could write 'log47'. + + You have: log2(32) + You want: + Definition: 5 + You have: log3(32) + You want: + Definition: 3.1546488 + You have: log4(32) + You want: + Definition: 2.5 + You have: log32(32) + You want: + Definition: 1 + You have: log(32) + You want: + Definition: 1.50515 + You have: log10(32) + You want: + Definition: 1.50515 + + If you wish to take roots of units, you may use the 'sqrt' or + 'cuberoot' functions. These functions require that the argument have + the appropriate root. You can obtain higher roots by using fractional exponents: You have: sqrt(acre) @@ -556,8 +588,8 @@ Unit not a root Previous Result - You can insert the result of the previous conversion using the under- - score ('_'). It is useful when you want to convert the same input to + You can insert the result of the previous conversion using the under- + score ('_'). It is useful when you want to convert the same input to several different units, for example You have: 2.3 tonrefrigeration @@ -569,11 +601,11 @@ * 8.0887615 / 0.12362832 - Suppose you want to do some deep frying that requires an oil depth of - 2 inches. You have 1/2 gallon of oil, and want to know the largest- + Suppose you want to do some deep frying that requires an oil depth of + 2 inches. You have 1/2 gallon of oil, and want to know the largest- diameter pan that will maintain the required depth. The nonlinear unit 'circlearea' gives the radius of the circle (see Other Nonlinear Units, - for a more detailed description) in SI units; you want the diameter in + for a more detailed description) in SI units; you want the diameter in inches: You have: 1|2 gallon / 2 in @@ -584,7 +616,7 @@ * 8.5749393 / 0.1166189 - In most cases, surrounding white space is optional, so the previous + In most cases, surrounding white space is optional, so the previous example could have used '2_'. If '_' follows a non-numerical unit sym- bol, however, the space is required: @@ -605,7 +637,7 @@ You want: Definition: 1 m^2 - Using '_' before a conversion has been performed (e.g., immediately + Using '_' before a conversion has been performed (e.g., immediately after invocation) generates an error: You have: _ @@ -627,24 +659,24 @@ _ = 1609.344 m _ = (1 / 0.00062137119) m - You can give '_' at the 'You want:' prompt, but it usually is not very + You can give '_' at the 'You want:' prompt, but it usually is not very useful. Complicated Unit Expressions - The 'units' program is especially helpful in ensuring accuracy and - dimensional consistency when converting lengthy unit expressions. For + The 'units' program is especially helpful in ensuring accuracy and + dimensional consistency when converting lengthy unit expressions. For example, one form of the Darcy-Weisbach fluid-flow equation is Delta P = (8 / pi)^2 (rho fLQ^2) / d^5, - where Delta P is the pressure drop, rho is the mass density, f is the - (dimensionless) friction factor, L is the length of the pipe, Q is the - volumetric flow rate, and d is the pipe diameter. It might be desired + where Delta P is the pressure drop, rho is the mass density, f is the + (dimensionless) friction factor, L is the length of the pipe, Q is the + volumetric flow rate, and d is the pipe diameter. It might be desired to have the equation in the form Delta P = A1 rho fLQ^2 / d^5 - that accepted the user's normal units; for typical units used in the + that accepted the user's normal units; for typical units used in the US, the required conversion could be something like You have: (8/pi^2)(lbm/ft^3)ft(ft^3/s)^2(1/in^5) @@ -652,9 +684,9 @@ * 43.533969 / 0.022970568 - The parentheses allow individual terms in the expression to be entered - naturally, as they might be read from the formula. Alternatively, the - multiplication could be done with the '*' rather than a space; then + The parentheses allow individual terms in the expression to be entered + naturally, as they might be read from the formula. Alternatively, the + multiplication could be done with the '*' rather than a space; then parentheses are needed only around 'ft^3/s' because of its exponent: You have: 8/pi^2 * lbm/ft^3 * ft * (ft^3/s)^2 /in^5 @@ -662,7 +694,7 @@ * 43.533969 / 0.022970568 - Without parentheses, and using spaces for multiplication, the previous + Without parentheses, and using spaces for multiplication, the previous conversion would need to be entered as You have: 8 lb ft ft^3 ft^3 / pi^2 ft^3 s^2 in^5 @@ -671,46 +703,46 @@ / 0.022970568 Backwards Compatibility: - '*' and '-' The original 'units' assigned multiplication a higher - precedence than division using the slash. This differs from the usual - precedence rules, which give multiplication and division equal prece- + '*' and '-' The original 'units' assigned multiplication a higher + precedence than division using the slash. This differs from the usual + precedence rules, which give multiplication and division equal prece- dence, and can be confusing for people who think of units as a calcula- tor. - The star operator ('*') included in this 'units' program has, by - default, the same precedence as division, and hence follows the usual - precedence rules. For backwards compatibility you can invoke 'units' - with the '--oldstar' option. Then '*' has a higher precedence than + The star operator ('*') included in this 'units' program has, by + default, the same precedence as division, and hence follows the usual + precedence rules. For backwards compatibility you can invoke 'units' + with the '--oldstar' option. Then '*' has a higher precedence than division, and the same precedence as multiplication using the space. - Historically, the hyphen ('-') has been used in technical publications + Historically, the hyphen ('-') has been used in technical publications to indicate products of units, and the original 'units' program treated - it as a multiplication operator. Because 'units' provides several - other ways to obtain unit products, and because '-' is a subtraction - operator in general algebraic expressions, 'units' treats the binary - '-' as a subtraction operator by default. For backwards compatibility - use the '--product' option, which causes 'units' to treat the binary + it as a multiplication operator. Because 'units' provides several + other ways to obtain unit products, and because '-' is a subtraction + operator in general algebraic expressions, 'units' treats the binary + '-' as a subtraction operator by default. For backwards compatibility + use the '--product' option, which causes 'units' to treat the binary '-' operator as a product operator. When '-' is a multiplication oper- - ator it has the same precedence as multiplication with a space, giving + ator it has the same precedence as multiplication with a space, giving it a higher precedence than division. - When '-' is used as a unary operator it negates its operand. Regard- - less of the 'units' options, if '-' appears after '(' or after '+' then - it will act as a negation operator. So you can always compute 20 - degrees minus 12 minutes by entering '20 degrees + -12 arcmin'. You + When '-' is used as a unary operator it negates its operand. Regard- + less of the 'units' options, if '-' appears after '(' or after '+', + then it will act as a negation operator. So you can always compute 20 + degrees minus 12 minutes by entering '20 degrees + -12 arcmin'. You must use this construction when you define new units because you cannot know what options will be in force when your definition is processed. NONLINEAR UNIT CONVERSIONS - Nonlinear units are represented using functional notation. They make + Nonlinear units are represented using functional notation. They make possible nonlinear unit conversions such as temperature. Temperature Conversions - Conversions between temperatures are different from linear conversions - between temperature increments--see the example below. The absolute - temperature conversions are handled by units starting with 'temp', and - you must use functional notation. The temperature-increment conver- - sions are done using units starting with 'deg' and they do not require + Conversions between temperatures are different from linear conversions + between temperature increments--see the example below. The absolute + temperature conversions are handled by units starting with 'temp', and + you must use functional notation. The temperature-increment conver- + sions are done using units starting with 'deg' and they do not require functional notation. You have: tempF(45) @@ -722,12 +754,12 @@ * 25 / 0.04 - Think of 'tempF(x)' not as a function but as a notation that indicates - that x should have units of 'tempF' attached to it. See Defining Non- - linear Units. The first conversion shows that if it's 45 degrees - Fahrenheit outside, it's 7.2 degrees Celsius. The second conversion - indicates that a change of 45 degrees Fahrenheit corresponds to a - change of 25 degrees Celsius. The conversion from 'tempF(x)' is to + Think of 'tempF(x)' not as a function but as a notation that indicates + that x should have units of 'tempF' attached to it. See Defining Non- + linear Units. The first conversion shows that if it's 45 degrees + Fahrenheit outside, it's 7.2 degrees Celsius. The second conversion + indicates that a change of 45 degrees Fahrenheit corresponds to a + change of 25 degrees Celsius. The conversion from 'tempF(x)' is to absolute temperature, so that You have: tempF(45) @@ -742,7 +774,7 @@ * 504.67 / 0.0019814929 - But if you convert 'tempF(x)' to 'degC', the output is probably not + But if you convert 'tempF(x)' to 'degC', the output is probably not what you expect: You have: tempF(45) @@ -750,12 +782,12 @@ * 280.37222 / 0.0035666871 - The result is the temperature in K, because 'degC' is defined as 'K', + The result is the temperature in K, because 'degC' is defined as 'K', the Kelvin. For consistent results, use the 'tempX' units when convert- ing to a temperature rather than converting a temperature increment. - The 'tempC()' and 'tempF()' definitions are limited to positive abso- - lute temperatures, and giving a value that would result in a negative + The 'tempC()' and 'tempF()' definitions are limited to positive abso- + lute temperatures, and giving a value that would result in a negative absolute temperature generates an error message: You have: tempC(-275) @@ -764,14 +796,14 @@ ^ Other Nonlinear Units - Some other examples of nonlinear units are numerous different ring - sizes and wire gauges, the grit sizes used for abrasives, the decibel - scale, shoe size, scales for the density of sugar (e.g., baume). The + Some other examples of nonlinear units are numerous different ring + sizes and wire gauges, the grit sizes used for abrasives, the decibel + scale, shoe size, scales for the density of sugar (e.g., baume). The standard data file also supplies units for computing the area of a cir- - cle and the volume of a sphere. See the standard units data file for - more details. Wire gauges with multiple zeroes are signified using - negative numbers where two zeroes is '-1'. Alternatively, you can use - the synonyms 'g00', 'g000', and so on that are defined in the standard + cle and the volume of a sphere. See the standard units data file for + more details. Wire gauges with multiple zeroes are signified using + negative numbers where two zeroes is '-1'. Alternatively, you can use + the synonyms 'g00', 'g000', and so on that are defined in the standard units data file. You have: wiregauge(11) @@ -792,14 +824,14 @@ You want: grit_ansicoated 342.76923 - The last example shows the conversion from P graded sand paper, which - is the European standard and may be marked ``P600'' on the back, to the + The last example shows the conversion from P graded sand paper, which + is the European standard and may be marked "P600" on the back, to the USA standard. - You can compute the area of a circle using the nonlinear unit, - 'circlearea'. You can also do this using the circularinch or cir- + You can compute the area of a circle using the nonlinear unit, + 'circlearea'. You can also do this using the circularinch or cir- cleinch. The next example shows two ways to compute the area of a cir- - cle with a five inch radius and one way to compute the volume of a + cle with a five inch radius and one way to compute the volume of a sphere with a radius of one meter. You have: circlearea(5 in) @@ -824,10 +856,10 @@ You want: Definition: 11 - You can give a nonlinear unit definition without an argument or paren- + You can give a nonlinear unit definition without an argument or paren- theses, and press Enter at the 'You want:' prompt to get the definition - of a nonlinear unit; if the definition is not valid for all real num- - bers, the range of validity is also given. If the definition requires + of a nonlinear unit; if the definition is not valid for all real num- + bers, the range of validity is also given. If the definition requires specific units this information is also displayed: You have: tempC @@ -840,16 +872,16 @@ Definition: circlearea(r) = pi r^2 r has units m - To see the definition of the inverse use the '~' notation. In this - case the parameter in the functional definition will usually be the - name of the unit. Note that the inverse for 'tempC' shows that it + To see the definition of the inverse use the '~' notation. In this + case the parameter in the functional definition will usually be the + name of the unit. Note that the inverse for 'tempC' shows that it requires units of 'K' in the specification of the allowed range of val- ues. Nonlinear unit conversions are described in more detail in Defin- ing Nonlinear Units. UNIT LISTS: CONVERSION TO SUMS OF UNITS - Outside of the SI, it is sometimes desirable to convert a single unit - to a sum of units--for example, feet to feet plus inches. The conver- + Outside of the SI, it is sometimes desirable to convert a single unit + to a sum of units--for example, feet to feet plus inches. The conver- sion from sums of units was described in Sums and Differences of Units, and is a simple matter of adding the units with the '+' sign: @@ -858,8 +890,8 @@ * 12.28125 / 0.081424936 - Although you can similarly write a sum of units to convert to, the - result will not be the conversion to the units in the sum, but rather + Although you can similarly write a sum of units to convert to, the + result will not be the conversion to the units in the sum, but rather the conversion to the particular sum that you have entered: You have: 12.28125 ft @@ -867,8 +899,8 @@ * 11.228571 / 0.089058524 - The unit expression given at the 'You want:' prompt is equivalent to - asking for conversion to multiples of '1 ft + 1 in + 1|8 in', which is + The unit expression given at the 'You want:' prompt is equivalent to + asking for conversion to multiples of '1 ft + 1 in + 1|8 in', which is 1.09375 ft, so the conversion in the previous example is equivalent to You have: 12.28125 ft @@ -876,19 +908,19 @@ * 11.228571 / 0.089058524 - In converting to a sum of units like miles, feet and inches, you typi- - cally want the largest integral value for the first unit, followed by + In converting to a sum of units like miles, feet and inches, you typi- + cally want the largest integral value for the first unit, followed by the largest integral value for the next, and the remainder converted to - the last unit. You can do this conversion easily with 'units' using a - special syntax for lists of units. You must list the desired units in - order from largest to smallest, separated by the semicolon (';') char- + the last unit. You can do this conversion easily with 'units' using a + special syntax for lists of units. You must list the desired units in + order from largest to smallest, separated by the semicolon (';') char- acter: You have: 12.28125 ft You want: ft;in;1|8 in 12 ft + 3 in + 3|8 in - The conversion always gives integer coefficients on the units in the + The conversion always gives integer coefficients on the units in the list, except possibly the last unit when the conversion is not exact: You have: 12.28126 ft @@ -906,18 +938,18 @@ 6 lb + 9.8218858 oz Listing ounces before pounds produces a technically correct result, but - not a very useful one. You must list the units in descending order of + not a very useful one. You must list the units in descending order of size in order to get the most useful result. - Ending a unit list with the separator ';' has the same effect as - repeating the last unit on the list, so 'ft;in;1|8 in;' is equivalent + Ending a unit list with the separator ';' has the same effect as + repeating the last unit on the list, so 'ft;in;1|8 in;' is equivalent to 'ft;in;1|8 in;1|8 in'. With the example above, this gives You have: 12.28126 ft You want: ft;in;1|8 in; 12 ft + 3 in + 3|8 in + 0.00096 * 1|8 in - in effect separating the integer and fractional parts of the coeffi- + in effect separating the integer and fractional parts of the coeffi- cient for the last unit. If you instead prefer to round the last coef- ficient to an integer you can do this with the '--round' ('-r') option. With the previous example, the result is @@ -926,12 +958,12 @@ You want: ft;in;1|8 in 12 ft + 3 in + 3|8 in (rounded down to nearest 1|8 in) - When you use the '-r' option, repeating the last unit on the list has - no effect (e.g., 'ft;in;1|8 in;1|8 in' is equivalent to 'ft;in;1|8 - in'), and hence neither does ending a list with a ';'. With a single + When you use the '-r' option, repeating the last unit on the list has + no effect (e.g., 'ft;in;1|8 in;1|8 in' is equivalent to 'ft;in;1|8 + in'), and hence neither does ending a list with a ';'. With a single unit and the '-r' option, a terminal ';' does have an effect: it causes - 'units' to treat the single unit as a list and produce a rounded value - for the single unit. Without the extra ';', the '-r' option has no + 'units' to treat the single unit as a list and produce a rounded value + for the single unit. Without the extra ';', the '-r' option has no effect on single unit conversions. This example shows the output using the '-r' option: @@ -944,8 +976,8 @@ You want: in; 147 in (rounded down to nearest in) - Each unit that appears in the list must be conformable with the first - unit on the list, and of course the listed units must also be conform- + Each unit that appears in the list must be conformable with the first + unit on the list, and of course the listed units must also be conform- able with the unit that you enter at the 'You have:' prompt. You have: meter @@ -961,12 +993,12 @@ 1 m 0.45359237 kg - In the first case, 'units' reports the disagreement between units - appearing on the list. In the second case, 'units' reports disagree- - ment between the unit you entered and the desired conversion. This + In the first case, 'units' reports the disagreement between units + appearing on the list. In the second case, 'units' reports disagree- + ment between the unit you entered and the desired conversion. This conformability error is based on the first unit on the unit list. - Other common candidates for conversion to sums of units are angles and + Other common candidates for conversion to sums of units are angles and time: You have: 23.437754 deg @@ -977,53 +1009,53 @@ You want: hr;min;sec 7 hr + 13 min + 54.84 sec - In North America, recipes for cooking typically measure ingredients by - volume, and use units that are not always convenient multiples of each - other. Suppose that you have a recipe for 6 and you wish to make a - portion for 1. If the recipe calls for 2 1/2 cups of an ingredient, - you might wish to know the measurements in terms of measuring devices + In North America, recipes for cooking typically measure ingredients by + volume, and use units that are not always convenient multiples of each + other. Suppose that you have a recipe for 6 and you wish to make a + portion for 1. If the recipe calls for 2 1/2 cups of an ingredient, + you might wish to know the measurements in terms of measuring devices you have available, you could use 'units' and enter You have: (2+1|2) cup / 6 You want: cup;1|2 cup;1|3 cup;1|4 cup;tbsp;tsp;1|2 tsp;1|4 tsp 1|3 cup + 1 tbsp + 1 tsp - By default, if a unit in a list begins with fraction of the form 1|x - and its multiplier is an integer, the fraction is given as the product + By default, if a unit in a list begins with fraction of the form 1|x + and its multiplier is an integer, the fraction is given as the product of the multiplier and the numerator; for example, You have: 12.28125 ft You want: ft;in;1|8 in; 12 ft + 3 in + 3|8 in - In many cases, such as the example above, this is what is wanted, but - sometimes it is not. For example, a cooking recipe for 6 might call - for 5 1/4 cup of an ingredient, but you want a portion for 2, and your + In many cases, such as the example above, this is what is wanted, but + sometimes it is not. For example, a cooking recipe for 6 might call + for 5 1/4 cup of an ingredient, but you want a portion for 2, and your 1-cup measure is not available; you might try You have: (5+1|4) cup / 3 You want: 1|2 cup;1|3 cup;1|4 cup 3|2 cup + 1|4 cup - This result might be fine for a baker who has a 1 1/2-cup measure (and - recognizes the equivalence), but it may not be as useful to someone - with more limited set of measures, who does want to do additional cal- - culations, and only wants to know ``How many 1/2-cup measures to I need - to add?'' After all, that's what was actually asked. With the - '--show-factor' option, the factor will not be combined with a unity - numerator, so that you get + This result might be fine for a baker who has a 1 1/2-cup measure (and + recognizes the equivalence), but it may not be as useful to someone + with more limited set of measures, who does want to do additional cal- + culations, and only wants to know "How many 1/2-cup measures to I need + to add?" After all, that's what was actually asked. With the '--show- + factor' option, the factor will not be combined with a unity numerator, + so that you get You have: (5+1|4) cup / 3 You want: 1|2 cup;1|3 cup;1|4 cup 3 * 1|2 cup + 1|4 cup A user-specified fractional unit with a numerator other than 1 is never - overridden, however--if a unit list specifies '3|4 cup;1|2 cup', a - result equivalent to 1 1/2 cups will always be shown as '2 * 3|4 cup' + overridden, however--if a unit list specifies '3|4 cup;1|2 cup', a + result equivalent to 1 1/2 cups will always be shown as '2 * 3|4 cup' whether or not the '--show-factor' option is given. Some applications for unit lists may be less obvious. Suppose that you - have a postal scale and wish to ensure that it's accurate at 1 oz, but + have a postal scale and wish to ensure that it's accurate at 1 oz, but have only metric calibration weights. You might try You have: 1 oz @@ -1044,7 +1076,7 @@ cup;1|2 cup;1|3 cup;1|4 cup;tbsp;tsp;1|2 tsp;1|4 tsp - can be tedious to enter. The 'units' program provides shorthand names + can be tedious to enter. The 'units' program provides shorthand names for some common combinations: hms hours, minutes, seconds @@ -1052,7 +1084,7 @@ time years, days, hours, minutes and seconds usvol US cooking volume: cups and smaller - Using these shorthands, or unit list aliases, you can do the following + Using these shorthands, or unit list aliases, you can do the following conversions: You have: anomalisticyear @@ -1062,10 +1094,10 @@ You want: usvol 2 tbsp + 2 tsp - You cannot combine a unit list alias with other units: it must appear + You cannot combine a unit list alias with other units: it must appear alone at the 'You want:' prompt. - You can display the definition of a unit list alias by entering it at + You can display the definition of a unit list alias by entering it at the 'You have:' prompt: You have: dms @@ -1079,19 +1111,223 @@ You want: day;min;sec 365;348;45.974678 - Unlike the case of regular output, zeros are included in this output + Unlike the case of regular output, zeros are included in this output list: You have: liter You want: cup;1|2 cup;1|4 cup;tbsp 4;0;0;3.6280454 +USING CGS UNITS + The SI--an extension of the MKS (meter-kilogram-second) system--has + largely supplanted the older CGS (centimeter-gram-second) system, but + CGS units are still used in a few specialized fields, especially in + physics where they lead to a more elegant formulation of Maxwell's + equations. Conversions between SI and CGS involving mechanical units + are straightforward, involving powers of 10 (e.g., 1 m = 100 cm). Con- + versions involving electromagnetic units are more complicated, and + 'units' supports three different systems of CGS units: electrostatic + units (ESU), electromagnetic units (EMU), and the Gaussian system. The + differences between these systems arise from different choices made for + proportionality constants in electromagnetic equations. Coulomb's law + gives electrostatic force between two charges separated by a distance + delim $$ r: + + F = k_C q_1 q_2 / r^2. + + Ampere's law gives the electromagnetic force per unit length between + two current-carrying conductors separated by a distance r: + + F/l = 2 k_A I_1 I_2 / r. + + The two constants, k_C and k_A, are related by the square of the speed + of light: k_A = k_C / c^2. + + In the SI, the constants have dimensions, and an additional base unit, + the ampere, measures electric current. The CGS systems do not define + new base units, but express charge and current as derived units in + terms of mass, length, and time. In the ESU system, the constant for + Coulomb's law is chosen to be unity and dimensionless, which defines + the unit of charge. In the EMU system, the constant for Ampere's law + is chosen to be unity and dimensionless, which defines a unit of cur- + rent. The Gaussian system usually uses the ESU units for charge and + current; it chooses another constant so that the units for the electric + and magnetic fields are the same. + + The dimensions of electrical quantities in the various CGS systems are + different from the SI dimensions for the same units; strictly, conver- + sions between these systems and SI are not possible. But units in dif- + ferent systems relate to the same physical quantities, so there is a + correspondence between these units. The 'units' program defines the + units so that you can convert between corresponding units in the vari- + ous systems. + + Specifying CGS Units + The CGS definitions involve cm^(1/2) and g^(1/2), which is problematic + because 'units' does not normally support fractional roots of base + units. The '--units' ('-u') option allows selection of a CGS unit sys- + tem and works around this restriction by introducing base units for the + square roots of length and mass: 'sqrt_cm' and 'sqrt_g'. The centime- + ter then becomes 'sqrt_cm^2' and the gram, 'sqrt_g^2'. This allows + working from equations using the units in the CGS system, and enforcing + dimensional conformity within that system. Recognized arguments to the + '--units' option are 'gauss[ian]', 'esu', 'emu', and 'si'; the argument + is case insensitive. The default mode for 'units' is SI units; the + only effect of giving 'si' with the '--units' option is to prepend + '(SI)' to the 'You have:' prompt. Giving an unrecognized system gener- + ates a warning, and 'units' uses SI units. + + The changes resulting from the '--units' option are actually controlled + by the 'UNITS_SYSTEM' environment variable. If you frequently work + with one of the supported CGS units systems, you may set this environ- + ment variable rather than giving the '--units' option at each invoca- + tion. As usual, an option given on the command line overrides the set- + ting of the environment variable. For example, if you would normally + work with Gaussian units but might occasionally work with SI, you could + set 'UNITS_SYSTEM' to 'gaussian' and specify SI with the '--units' + option. Unlike the argument to the '--units' option, the value of + 'UNITS_SYSTEM' is case sensitive, so setting a value of 'EMU' will have + no effect other than to give an error message and set SI units. + + The CGS definitions appear as conditional settings in the standard + units data file, which you can consult for more information on how + these units are defined, or on how to define an alternate units system. + + CGS Units Systems + The ESU system derives the electromagnetic units from its unit of + charge, the statcoulomb, which is defined from Coulomb's law. The + statcoulomb equals dyne^(1/2) cm, or cm^(3/2) g^(1/2) s^(-1). The unit + of current, the statampere, is statcoulomb sec, analogous to the rela- + tionship in SI. Other electrical units are then derived in a manner + similar to that for SI units; the units use the SI names prefixed by + 'stat-', e.g., 'statvolt' or 'statV'. The prefix 'st-' is also recog- + nized (e.g., 'stV'). + + The EMU system derives the electromagnetic units from its unit of cur- + rent, the abampere, which is defined in terms of Ampere's law. The + abampere is equal to dyne^(1/2), or cm^(1/2) g^(1/2) s^(-1). delim off + The unit of charge, the abcoulomb, is abampere sec, again analogous to + the SI relationship. Other electrical units are then derived in a man- + ner similar to that for SI units; the units use the SI names prefixed + by 'ab-', e.g., 'abvolt' or 'abV'. The magnetic field units include + the gauss, the oersted and the maxwell. + + The Gaussian units system, which was also known as the Symmetric Sys- + tem, uses the same charge and current units as the ESU system (e.g., + 'statC', 'statA'); it differs by defining the magnetic field so that it + has the same units as the electric field. The resulting magnetic field + units are the same ones used in the EMU system: the gauss, the oersted + and the maxwell. + + Conversions Between Different Systems + The CGS systems define units that measure the same thing but may have + conflicting dimensions. Furthermore, the dimensions of the electromag- + netic CGS units are never compatible with SI. But if you measure + charge in two different systems you have measured the same physical + thing, so there is a correspondence between the units in the different + systems, and 'units' supports conversions between corresponding units. + When running with SI, 'units' defines all of the CGS units in terms of + SI. When you select a CGS system, 'units' defines the SI units and the + other CGS system units in terms of the system you have selected. + + (Gaussian) You have: statA + You want: abA + * 3.335641e-11 + / 2.9979246e+10 + (Gaussian) You have: abA + You want: sqrt(dyne) + conformability error + 2.9979246e+10 sqrt_cm^3 sqrt_g / s^2 + 1 sqrt_cm sqrt_g / s + + In the above example, 'units' converts between the current units statA + and abA even though the abA, from the EMU system, has incompatible + dimensions. This works because in Gaussian mode, the abA is defined in + terms of the statA, so it does not have the correct definition for EMU; + consequently, you cannot convert the abA to its EMU definition. + + One challenge of conversion is that because the CGS system has fewer + base units, quantities that have different dimensions in SI may have + the same dimension in a CGS system. And yet, they may not have the + same conversion factor. For example, the unit for the E field and B + fields are the same in the Gaussian system, but the conversion factors + to SI are quite different. This means that correct conversion is only + possible if you keep track of what quantity is being measured. You + cannot convert statV/cm to SI without indicating which type of field + the unit measures. To aid in dimensional analysis, 'units' defines + various dimension units such as LENGTH, TIME, and CHARGE to be the + appropriate dimension in SI. The electromagnetic dimensions such as + B_FIELD or E_FIELD may be useful aids both for conversion and dimen- + sional analysis in CGS. You can convert them to or from CGS in order + to perform SI conversions that in some cases will not work directly due + to dimensional incompatibilities. This example shows how the Gaussian + system uses the same units for all of the fields, but they all have + different conversion factors with SI. + + (Gaussian) You have: statV/cm + You want: E_FIELD + * 29979.246 + / 3.335641e-05 + (Gaussian) You have: statV/cm + You want: B_FIELD + * 0.0001 + / 10000 + (Gaussian) You have: statV/cm + You want: H_FIELD + * 79.577472 + / 0.012566371 + (Gaussian) You have: statV/cm + You want: D_FIELD + * 2.6544187e-07 + / 3767303.1 + + The next example shows that the oersted cannot be converted directly to + the SI unit of magnetic field, A/m, because the dimensions conflict. + We cannot redefine the ampere to make this work because then it would + not convert with the statampere. But you can still do this conversion + as shown below. + + (Gaussian) You have: oersted + You want: A/m + conformability error + 1 sqrt_g / s sqrt_cm + 29979246 sqrt_cm sqrt_g / s^2 + (Gaussian) You have: oersted + You want: H_FIELD + * 79.577472 + / 0.012566371 + + Prompt Prefix + If a unit system is specified with the '--units' option, the selected + system's name is prepended to the 'You have:' prompt as a reminder, + e.g., + + (Gaussian) You have: stC + You want: + Definition: statcoulomb = sqrt(dyne) cm = 1 sqrt_cm^3 sqrt_g / s + + You can suppressed the prefix by including a line + + !prompt + + with no argument in a site or personal units data file. The prompt can + be conditionally suppressed by including such a line within '!var' + '!endvar' constructs, e.g., + + !var UNITS_SYSTEM gaussian gauss + !prompt + !endvar + + This might be appropriate if you normally use Gaussian units and find + the prefix distracting but want to be reminded when you have selected a + different CGS system. + LOGGING CALCULATIONS - The '--log' option allows you to save the results of calculations in a - file; this can be useful if you need a permanent record of your work. + The '--log' option allows you to save the results of calculations in a + file; this can be useful if you need a permanent record of your work. For example, the fluid-flow conversion in Complicated Unit Expressions, is lengthy, and if you were to use it in designing a piping system, you - might want a record of it for the project file. If the interactive + might want a record of it for the project file. If the interactive session # Conversion factor A1 for pressure drop @@ -1114,11 +1350,11 @@ The time is written to the log file when the file is opened. - The use of comments can help clarify the meaning of calculations for - the log. The log includes conformability errors between the units at - the 'You have:' and 'You want:' prompts, but not other errors, includ- - ing lack of conformability of items in sums or differences or among - items in a unit list. For example, a conversion between zenith angle + The use of comments can help clarify the meaning of calculations for + the log. The log includes conformability errors between the units at + the 'You have:' and 'You want:' prompts, but not other errors, includ- + ing lack of conformability of items in sums or differences or among + items in a unit list. For example, a conversion between zenith angle and elevation angle could involve You have: 90 deg - (5 deg + 22 min + 9 sec) @@ -1143,15 +1379,15 @@ * 84.630833 / 0.011816024 - The initial entry error (forgetting that minutes have dimension of - time, and that arcminutes must be used for dimensions of angle) does - not appear in the output. When converting to a unit list alias, + The initial entry error (forgetting that minutes have dimension of + time, and that arcminutes must be used for dimensions of angle) does + not appear in the output. When converting to a unit list alias, 'units' expands the alias in the log file. - The 'From:' and 'To:' tags are written to the log file even if the - '--quiet' option is given. If the log file exists when 'units' is - invoked, the new results are appended to the log file. The time is - written to the log file each time the file is opened. The '--log' + The 'From:' and 'To:' tags are written to the log file even if the + '--quiet' option is given. If the log file exists when 'units' is + invoked, the new results are appended to the log file. The time is + written to the log file each time the file is opened. The '--log' option is ignored when 'units' is used non-interactively. INVOKING UNITS @@ -1160,129 +1396,131 @@ units [options] [from-unit [to-unit]] If the from-unit and to-unit are omitted, the program will use interac- - tive prompts to determine which conversions to perform. See Interac- - tive Use. If both from-unit and to-unit are given, 'units' will print - the result of that single conversion and then exit. If only from-unit - appears on the command line, 'units' will display the definition of + tive prompts to determine which conversions to perform. See Interac- + tive Use. If both from-unit and to-unit are given, 'units' will print + the result of that single conversion and then exit. If only from-unit + appears on the command line, 'units' will display the definition of that unit and exit. Units specified on the command line may need to be quoted to protect them from shell interpretation and to group them into - two arguments. See Command Line Use. + two arguments. Note also that the '--quiet' option is enabled by + default if you specify from-unit on the command line. See Command Line + Use. The default behavior of 'units' can be changed by various options given on the command line. In most cases, the options may be given in either - short form (a single '-' followed by a single character) or long form - ('--' followed by a word or hyphen-separated words). Short-form - options are cryptic but require less typing; long-form options require - more typing but are more explanatory and may be more mnemonic. With + short form (a single '-' followed by a single character) or long form + ('--' followed by a word or hyphen-separated words). Short-form + options are cryptic but require less typing; long-form options require + more typing but are more explanatory and may be more mnemonic. With long-form options you need only enter sufficient characters to uniquely identify the option to the program. For example, '--out %f' works, but - '--o %f' fails because 'units' has other long options beginning with - 'o'. However, '--q' works because '--quiet' is the only long option + '--o %f' fails because 'units' has other long options beginning with + 'o'. However, '--q' works because '--quiet' is the only long option beginning with 'q'. - Some options require arguments to specify a value (e.g., '-d 12' or - '--digits 12'). Short-form options that do not take arguments may be - concatenated (e.g., '-erS' is equivalent to '-e -r -S'); the last - option in such a list may be one that takes an argument (e.g., - '-ed 12'). With short-form options, the space between an option and - its argument is optional (e.g., '-d12' is equivalent to '-d 12'). - Long-form options may not be concatenated, and the space between a - long-form option and its argument is required. Short-form and long- - form options may be intermixed on the command line. Options may be - given in any order, but when incompatible options (e.g., '--output- + Some options require arguments to specify a value (e.g., '-d 12' or + '--digits 12'). Short-form options that do not take arguments may be + concatenated (e.g., '-erS' is equivalent to '-e -r -S'); the last + option in such a list may be one that takes an argument (e.g., + '-ed 12'). With short-form options, the space between an option and + its argument is optional (e.g., '-d12' is equivalent to '-d 12'). + Long-form options may not be concatenated, and the space between a + long-form option and its argument is required. Short-form and long- + form options may be intermixed on the command line. Options may be + given in any order, but when incompatible options (e.g., '--output- format' and '--exponential') are given in combination, behavior is con- - trolled by the last option given. For example, '-o%.12f -e' gives + trolled by the last option given. For example, '-o%.12f -e' gives exponential format with the default eight significant digits). The following options are available: -c, --check Check that all units and prefixes defined in the units data file - reduce to primitive units. Print a list of all units that can- - not be reduced. Also display some other diagnostics about sus- - picious definitions in the units data file. Only definitions + reduce to primitive units. Print a list of all units that can- + not be reduced. Also display some other diagnostics about sus- + picious definitions in the units data file. Only definitions active in the current locale are checked. You should always run 'units' with this option after modifying a units data file. --check-verbose, --verbose-check - Like the '--check' option, this option prints a list of units + Like the '--check' option, this option prints a list of units that cannot be reduced. But to help find unit definitions that cause endless loops, it lists the units as they are checked. If - 'units' hangs, then the last unit to be printed has a bad defi- - nition. Only definitions active in the current locale are + 'units' hangs, then the last unit to be printed has a bad defi- + nition. Only definitions active in the current locale are checked. -d ndigits, --digits ndigits - Set the number of significant digits in the output to the value - specified (which must be greater than zero). For example, + Set the number of significant digits in the output to the value + specified (which must be greater than zero). For example, '-d 12' sets the number of significant digits to 12. With expo- - nential output 'units' displays one digit to the left of the - decimal point and eleven digits to the right of the decimal - point. On most systems, the maximum number of internally mean- - ingful digits is 15; if you specify a greater number than your - system's maximum, 'units' will print a warning and set the num- - ber to the largest meaningful value. To directly set the maxi- - mum value, give an argument of 'max' (e.g., '-d max'). Be - aware, of course, that ``significant'' here refers only to the - display of numbers; if results depend on physical constants not + nential output 'units' displays one digit to the left of the + decimal point and eleven digits to the right of the decimal + point. On most systems, the maximum number of internally mean- + ingful digits is 15; if you specify a greater number than your + system's maximum, 'units' will print a warning and set the num- + ber to the largest meaningful value. To directly set the maxi- + mum value, give an argument of 'max' (e.g., '-d max'). Be + aware, of course, that "significant" here refers only to the + display of numbers; if results depend on physical constants not known to this precision, the physically meaningful precision may - be less than that shown. The '--digits' option conflicts with + be less than that shown. The '--digits' option conflicts with the '--output-format' option. -e, --exponential - Set the numeric output format to exponential (i.e., scientific - notation), like that used in the Unix 'units' program. The - default precision is eight significant digits (seven digits to - the right of the decimal point); this can be changed with the - '--digits' option. The '--exponential' option conflicts with + Set the numeric output format to exponential (i.e., scientific + notation), like that used in the Unix 'units' program. The + default precision is eight significant digits (seven digits to + the right of the decimal point); this can be changed with the + '--digits' option. The '--exponential' option conflicts with the '--output-format' option. -o format, --output-format format - This option affords complete control over the numeric output + This option affords complete control over the numeric output format using the specified format. The format is a single float- - ing point numeric format for the 'printf()' function in the C - programming language. All compilers support the format types - 'g' and 'G' to specify significant digits, 'e' and 'E' for sci- - entific notation, and 'f' for fixed-point decimal. The ISO C99 + ing point numeric format for the 'printf()' function in the C + programming language. All compilers support the format types + 'g' and 'G' to specify significant digits, 'e' and 'E' for sci- + entific notation, and 'f' for fixed-point decimal. The ISO C99 standard introduced the 'F' type for fixed-point decimal and the - 'a' and 'A' types for hexadecimal floating point; these types - are allowed with compilers that support them. The default for- - mat is '%.8g'; for greater precision, you could specify + 'a' and 'A' types for hexadecimal floating point; these types + are allowed with compilers that support them. The default for- + mat is '%.8g'; for greater precision, you could specify '-o %.15g'. See Numeric Output Format and the documentation for 'printf()' for more detailed descriptions of the format specifi- - cation. The '--output-format' option affords the greatest con- + cation. The '--output-format' option affords the greatest con- trol of the output appearance, but requires at least rudimentary knowledge of the 'printf()' format syntax. If you don't want to - bother with the 'printf()' syntax, you can specify greater pre- + bother with the 'printf()' syntax, you can specify greater pre- cision more simply with the '--digits' option or select exponen- - tial format with '--exponential'. The '--output-format' option + tial format with '--exponential'. The '--output-format' option is incompatible with the '--exponential' and '--digits' options. -f filename, --file filename Instruct 'units' to load the units file filename. You can spec- ify up to 25 units files on the command line. When you use this option, 'units' will load only the files you list on the command - line; it will not load the standard file or your personal units - file unless you explicitly list them. If filename is the empty - string ('-f ""'), the default units file (or that specified by - 'UNITSFILE') will be loaded in addition to any others specified + line; it will not load the standard file or your personal units + file unless you explicitly list them. If filename is the empty + string ('-f ""'), the default units file (or that specified by + 'UNITSFILE') will be loaded in addition to any others specified with '-f'. -L logfile, --log logfile - Save the results of calculations in the file logfile; this can - be useful if it is important to have a record of unit conver- - sions or other calculations that are to be used extensively or - in a critical activity such as a program or design project. If - logfile exits, the new results are appended to the file. This - option is ignored when 'units' is used non-interactively. See - Logging Calculations for a more detailed description and some + Save the results of calculations in the file logfile; this can + be useful if it is important to have a record of unit conver- + sions or other calculations that are to be used extensively or + in a critical activity such as a program or design project. If + logfile exits, the new results are appended to the file. This + option is ignored when 'units' is used non-interactively. See + Logging Calculations for a more detailed description and some examples. -H filename, --history filename - Instruct 'units' to save history to filename, so that a record - of your commands is available for retrieval across different - 'units' invocations. To prevent the history from being saved - set filename to the empty string ('-H ""'). This option has no + Instruct 'units' to save history to filename, so that a record + of your commands is available for retrieval across different + 'units' invocations. To prevent the history from being saved + set filename to the empty string ('-H ""'). This option has no effect if readline is not available. -h, --help @@ -1293,13 +1531,13 @@ the default behavior. -p, --product - Causes '-' to be interpreted as a multiplication operator when + Causes '-' to be interpreted as a multiplication operator when it has two operands. It will act as a negation operator when it - has only one operand: '(-3)'. By default '-' is treated as a + has only one operand: '(-3)'. By default '-' is treated as a subtraction operator. --oldstar - Causes '*' to have the old-style precedence, higher than the + Causes '*' to have the old-style precedence, higher than the precedence of division so that '1/2*3' will equal '1/6'. --newstar @@ -1307,61 +1545,28 @@ usual rules of algebra: the precedence of '*' is the same as the precedence of '/', so that '1/2*3' will equal '3/2'. - --compact - Give compact output featuring only the conversion factor. This - turns off the '--verbose' option. - - -q, --quiet, --silent - Suppress prompting of the user for units and the display of sta- - tistics about the number of units loaded. - - -n, --nolists - Disable conversion to unit lists. - -r, --round - When converting to a combination of units given by a unit list, - round the value of the last unit in the list to the nearest + When converting to a combination of units given by a unit list, + round the value of the last unit in the list to the nearest integer. -S, --show-factor - When converting to a combination of units specified in a list, - always show a non-unity factor before a unit that begins with a + When converting to a combination of units specified in a list, + always show a non-unity factor before a unit that begins with a fraction with a unity denominator. By default, if the unit in a - list begins with fraction of the form 1|x and its multiplier is + list begins with fraction of the form 1|x and its multiplier is an integer other than 1, the fraction is given as the product of - the multiplier and the numerator (e.g., '3|8 in' rather than '3 - * 1|8 in'). In some cases, this is not what is wanted; for - example, the results for a cooking recipe might show '3 * - 1|2 cup' as '3|2 cup'. With the '--show-factor' option, a - result equivalent to 1.5 cups will display as '3 * 1|2 cup' - rather than '3|2 cup'. A user-specified fractional unit with a - numerator other than 1 is never overridden, however--if a unit - list specifies '3|4 cup;1|2 cup', a result equivalent to 1 1/2 - cups will always be shown as '2 * 3|4 cup' whether or not the + the multiplier and the numerator (e.g., '3|8 in' rather than '3 + * 1|8 in'). In some cases, this is not what is wanted; for + example, the results for a cooking recipe might show '3 * + 1|2 cup' as '3|2 cup'. With the '--show-factor' option, a + result equivalent to 1.5 cups will display as '3 * 1|2 cup' + rather than '3|2 cup'. A user-specified fractional unit with a + numerator other than 1 is never overridden, however--if a unit + list specifies '3|4 cup;1|2 cup', a result equivalent to 1 1/2 + cups will always be shown as '2 * 3|4 cup' whether or not the '--show-factor' option is given. - -s, --strict - Suppress conversion of units to their reciprocal units. For - example, 'units' will normally convert hertz to seconds because - these units are reciprocals of each other. The strict option - requires that units be strictly conformable to perform a conver- - sion, and will give an error if you attempt to convert hertz to - seconds. - - -1, --one-line - Give only one line of output (the forward conversion). Do not - print the reverse conversion. If a reciprocal conversion is - performed then 'units' will still print the ``reciprocal conver- - sion'' line. - - -t, --terse - Give terse output when converting units. This option can be - used when calling 'units' from another program so that the out- - put is easy to parse. This option has the combined effect of - these options: '--strict' '--quiet' '--one-line' '--compact'. - When combined with '--version' it produces a display showing - only the program name and version number. - -v, --verbose Give slightly more verbose output when converting units. When combined with the '-c' option this gives the same effect as @@ -1375,104 +1580,246 @@ data file, and the location of the personal units data file; indicate if the personal units data file does not exist. - When given in combination with the '--terse' option, the program prints - only the version number and exits. + When given in combination with the '--terse' option, the program + prints only the version number and exits. - When given in combination with the '--verbose' option, the program, the - '--version' option has the same effect as the '--info' option below. + When given in combination with the '--verbose' option, the pro- + gram, the '--version' option has the same effect as the '--info' + option below. -I, --info - Print the information given with the '--version' option, show - the pathname of the units program, show the status of the - 'UNITSFILE' and 'MYUNITSFILE' environment variables, and addi- - tional information about how 'units' locates the related files. - On systems running Microsoft Windows, the status of the - 'UNITSLOCALE' environment variable and information about the - related locale map are also given. This option is usually of + Print the information given with the '--version' option, show + the pathname of the units program, show the status of the + 'UNITSFILE' and 'MYUNITSFILE' environment variables, and addi- + tional information about how 'units' locates the related files. + On systems running Microsoft Windows, the status of the + 'UNITSLOCALE' environment variable and information about the + related locale map are also given. This option is usually of interest only to developers and administrators, but it can some- times be useful for troubleshooting. - Combining the '--version' and '--verbose' options has the same effect - as giving '--info'. + Combining the '--version' and '--verbose' options has the same + effect as giving '--info'. -U, --unitsfile - Print the location of the default units data file and exit; if - the file cannot be found, print ``Units data file not found''. + Print the location of the default units data file and exit; if + the file cannot be found, print "Units data file not found". + + -u (gauss[ian]|esu|emu), --units (gauss[ian]|esu|emu) + Specify a CGS units system: Gaussian, ESU, or EMU. -l locale, --locale locale - Print the information given with the '--version' option, show - the Force a specified locale such as 'en_GB' to get British def- - initions by default. This overrides the locale determined from + Force a specified locale such as 'en_GB' to get British defini- + tions by default. This overrides the locale determined from system settings or environment variables. See Locale for a description of locale format. + -n, --nolists + Disable conversion to unit lists. + + -s, --strict + Suppress conversion of units to their reciprocal units. For + example, 'units' will normally convert hertz to seconds because + these units are reciprocals of each other. The strict option + requires that units be strictly conformable to perform a conver- + sion, and will give an error if you attempt to convert hertz to + seconds. + + -1, --one-line + Give only one line of output (the forward conversion); do not + print the reverse conversion. If a reciprocal conversion is + performed, then 'units' will still print the "reciprocal conver- + sion" line. + + -t, --terse + Print only a single conversion factor. This option can be used + when calling 'units' from another program so that the output is + easy to parse. This option has the combined effect of these + options: '--strict' '--quiet' '--one-line' '--compact'. When + combined with '--version' it produces a display showing only the + program name and version number. + + --compact + Give compact output featuring only the conversion factor; the + multiplication and division signs are not shown, and there is no + leading whitespace. If you convert to a unit list, then the + output is a semicolon separated list of factors. This turns off + the '--verbose' option. + + -q, --quiet, --silent + Suppress the display of statistics about the number of units + loaded, any messages printed by the units database, and the + prompting of the user for units. This option does not affect + how 'units' displays the results. This option is turned on by + default if you invoke 'units' with a unit expression on the com- + mand line. + +OUTPUT STYLES + The output can be tweaked in various ways using command line options. + With no options, the output looks like this + + $ units + Currency exchange rates from FloatRates (USD base) on 2019-02-20 + 3070 units, 109 prefixes, 109 nonlinear units + + You have: 23ft + You want: m + * 7.0104 + / 0.14264521 + You have: m + You want: ft;in + 3 ft + 3.3700787 in + + This is arguably a bit cryptic; the '--verbose' option makes clear what + the output means: + + $ units --verbose + Currency exchange rates from FloatRates (USD base) on 2019-02-20 + 3070 units, 109 prefixes, 109 nonlinear units + + You have: 23 ft + You want: m + 23 ft = 7.0104 m + 23 ft = (1 / 0.14264521) m + You have: meter + You want: ft;in + meter = 3 ft + 3.3700787 in + + The '--quiet' option suppresses the clutter displayed when 'units' + starts, as well as the prompts to the user. This option is enabled by + default when you give units on the command line. + + $ units --quiet + 23 ft + m + * 7.0104 + / 0.14264521 + + $ units 23ft m + * 7.0104 + / 0.14264521 + + The remaining style options allow you to display only numerical values + without the tab or the multiplication and division signs, or to display + just a single line showing the forward conversion: + + $ units --compact 23ft m + 7.0104 + 0.14264521 + + $ units --compact m 'ft;in' + 3;3.3700787 + + $ units --one-line 23ft m + * 7.0104 + + $ units --one-line 23ft 1/m + reciprocal conversion + * 0.14264521 + + $ units --one-line 23ft kg + conformability error + 7.0104 m + 1 kg + + Note that when converting to a unit list, the '--compact' option dis- + plays a semicolon separated list of results. Also be aware that the + 'one-line' option doesn't live up to its name if you execute a recipro- + cal conversion or if you get a conformability error. The former case + can be prevented using the '--strict' option, which suppresses recipro- + cal conversions. Similarly you can suppress unit list conversion using + '--nolists'. It is impossible to prevent the three line error output. + + $ units --compact --nolists m 'ft;in' + Error in 'ft;in': Parse error + + $ units --one-line --strict 23ft 1/m + + The various style options can be combined appropriately. The ultimate + combination is the '--terse' option, which combines '--strict', + '--quiet', '--one-line', and '--compact' to produce the minimal output, + just a single number for regular conversions and a semicolon separated + list for conversion to unit lists. This will likely be the best choice + for programs that want to call 'units' and then process its result. + + $ units --terse 23ft m + 7.0104 + + $ units --terse m 'ft;in' + 3;3.3700787 + + $ units --terse 23ft 1/m + conformability error + 7.0104 m + 1 / m + ADDING YOUR OWN DEFINITIONS Units Data Files - The units and prefixes that 'units' can convert are defined in the - units data file, typically '/usr/share/units/definitions.units'. If - you can't find this file, run 'units --version' to get information on - the file locations for your installation. Although you can extend or - modify this data file if you have appropriate user privileges, it's - usually better to put extensions in separate files so that the defini- + The units and prefixes that 'units' can convert are defined in the + units data file, typically '/usr/share/units/definitions.units'. If + you can't find this file, run 'units --version' to get information on + the file locations for your installation. Although you can extend or + modify this data file if you have appropriate user privileges, it's + usually better to put extensions in separate files so that the defini- tions will be preserved if you update 'units'. - You can include additional data files in the units database using the + You can include additional data files in the units database using the '!include' command in the standard units data file. For example !include /usr/local/share/units/local.units might be appropriate for a site-wide supplemental data file. The loca- - tion of the '!include' statement in the standard units data file is - important; later definitions replace earlier ones, so any definitions - in an included file will override definitions before the '!include' - statement in the standard units data file. With normal invocation, no - warning is given about redefinitions; to ensure that you don't have an - unintended redefinition, run 'units -c' after making changes to any + tion of the '!include' statement in the standard units data file is + important; later definitions replace earlier ones, so any definitions + in an included file will override definitions before the '!include' + statement in the standard units data file. With normal invocation, no + warning is given about redefinitions; to ensure that you don't have an + unintended redefinition, run 'units -c' after making changes to any units data file. - If you want to add your own units in addition to or in place of stan- - dard or site-wide supplemental units data files, you can include them + If you want to add your own units in addition to or in place of stan- + dard or site-wide supplemental units data files, you can include them in the '.units' file in your home directory. If this file exists it is - read after the standard units data file, so that any definitions in - this file will replace definitions of the same units in the standard - data file or in files included from the standard data file. This file - will not be read if any units files are specified on the command line. + read after the standard units data file, so that any definitions in + this file will replace definitions of the same units in the standard + data file or in files included from the standard data file. This file + will not be read if any units files are specified on the command line. (Under Windows the personal units file is named 'unitdef.units'.) Run- - ning 'units -V' will display the location and name of your personal + ning 'units -V' will display the location and name of your personal units file. - The 'units' program first tries to determine your home directory from + The 'units' program first tries to determine your home directory from the 'HOME' environment variable. On systems running Microsoft Windows, - if 'HOME' does not exist, 'units' attempts to find your home directory - from 'HOMEDRIVE', 'HOMEPATH' and 'USERPROFILE'. You can specify an - arbitrary file as your personal units data file with the 'MYUNITSFILE' - environment variable; if this variable exists, its value is used with- - out searching your home directory. The default units data files are + if 'HOME' does not exist, 'units' attempts to find your home directory + from 'HOMEDRIVE', 'HOMEPATH' and 'USERPROFILE'. You can specify an + arbitrary file as your personal units data file with the 'MYUNITSFILE' + environment variable; if this variable exists, its value is used with- + out searching your home directory. The default units data files are described in more detail in Data Files. Defining New Units and Prefixes - A unit is specified on a single line by giving its name and an equiva- - lence. Comments start with a '#' character, which can appear anywhere - in a line. The backslash character ('\') acts as a continuation char- + A unit is specified on a single line by giving its name and an equiva- + lence. Comments start with a '#' character, which can appear anywhere + in a line. The backslash character ('\') acts as a continuation char- acter if it appears as the last character on a line, making it possible to spread definitions out over several lines if desired. A file can be - included by giving the command '!include' followed by the file's name. - The '!' must be the first character on the line. The file will be - sought in the same directory as the parent file unless you give a full - path. The name of the file to be included cannot contain the comment - character '#'. - - Unit names must not contain any of the operator characters '+', '-', - '*', '/', '|', '^', ';', '~', the comment character '#', or parenthe- - ses. They cannot begin or end with an underscore ('_'), a comma (',') - or a decimal point ('.'). The figure dash (U+2012), typographical - minus (`-'; U+2212), and en dash (`-'; U+2013) are converted to the - operator '-', so none of these characters can appear in unit names. - Names cannot begin with a digit, and if a name ends in a digit other - than zero, the digit must be preceded by a string beginning with an - underscore, and afterwards consisting only of digits, decimal points, - or commas. For example, 'foo_2', 'foo_2,1', or 'foo_3.14' are valid - names but 'foo2' or 'foo_a2' are invalid. You could define nitrous + included by giving the command '!include' followed by the file's name. + The '!' must be the first character on the line. The file will be + sought in the same directory as the parent file unless you give a full + path. The name of the file to be included cannot contain spaces or the + comment character '#'. + + Unit names must not contain any of the operator characters '+', '-', + '*', '/', '|', '^', ';', '~', the comment character '#', or parenthe- + ses. They cannot begin or end with an underscore ('_'), a comma (',') + or a decimal point ('.'). The figure dash (U+2012), typographical + minus ('-'; U+2212), and en dash ('-'; U+2013) are converted to the + operator '-', so none of these characters can appear in unit names. + Names cannot begin with a digit, and if a name ends in a digit other + than zero, the digit must be preceded by a string beginning with an + underscore, and afterwards consisting only of digits, decimal points, + or commas. For example, 'foo_2', 'foo_2,1', or 'foo_3.14' are valid + names but 'foo2' or 'foo_a2' are invalid. You could define nitrous oxide as N2O nitrogen 2 + oxygen @@ -1482,27 +1829,34 @@ NO_2 nitrogen + oxygen 2 Be careful to define new units in terms of old ones so that a reduction - leads to the primitive units, which are marked with '!' characters. - Dimensionless units are indicated by using the string '!dimensionless' + leads to the primitive units, which are marked with '!' characters. + Dimensionless units are indicated by using the string '!dimensionless' for the unit definition. When adding new units, be sure to use the '-c' option to check that the - new units reduce properly. If you create a loop in the units defini- - tions, then 'units' will hang when invoked with the '-c' option. You - will need to use the '--check-verbose' option, which prints out each - unit as it is checked. The program will still hang, but the last unit + new units reduce properly. If you create a loop in the units defini- + tions, then 'units' will hang when invoked with the '-c' option. You + will need to use the '--check-verbose' option, which prints out each + unit as it is checked. The program will still hang, but the last unit printed will be the unit that caused the infinite loop. - If you define any units that contain '+' characters, carefully check - them because the '-c' option will not catch non-conformable sums. Be - careful with the '-' operator as well. When used as a binary operator, - the '-' character can perform addition or multiplication depending on - the options used to invoke 'units'. To ensure consistent behavior use - '-' only as a unary negation operator when writing units definitions. - To multiply two units leave a space or use the '*' operator with care, - recalling that it has two possible precedence values and may require - parentheses to ensure consistent behavior. To compute the difference - of 'foo' and 'bar' write 'foo+(-bar)' or even 'foo+-bar'. + If you define any units that contain '+' characters in their defini- + tions, carefully check them because the '-c' option will not catch non- + conformable sums. Be careful with the '-' operator as well. When used + as a binary operator, the '-' character can perform addition or multi- + plication depending on the options used to invoke 'units'. To ensure + consistent behavior use '-' only as a unary negation operator when + writing units definitions. To multiply two units leave a space or use + the '*' operator with care, recalling that it has two possible prece- + dence values and may require parentheses to ensure consistent behavior. + To compute the difference of 'foo' and 'bar' write 'foo+(-bar)' or even + 'foo+-bar'. + + You may wish to intentionally redefine a unit. When you do this, and + use the '-c' option, 'units' displays a warning message about the + redefinition. You can suppress these warnings by redefining a unit + using a '+' at the beginning of the unit name. Do not include any + white space between the '+' and the redefined unit name. Here is an example of a short data file that defines some basic units: @@ -1512,14 +1866,15 @@ micro- 1e-6 # Define a prefix minute 60 sec # A minute is 60 seconds hour 60 min # An hour is 60 minutes - inch 0.0254 m # Inch defined in terms of meters + inch 72 m # Inch defined incorrectly terms of meters ft 12 inches # The foot defined in terms of inches mile 5280 ft # And the mile + +inch 0.0254 m # Correct redefinition, warning suppressed A unit that ends with a '-' character is a prefix. If a prefix defini- tion contains any '/' characters, be sure they are protected by paren- - theses. If you define 'half- 1/2' then 'halfmeter' would be equivalent - to '1 / (2 meter)'. + theses. If you define 'half- 1/2', then 'halfmeter' would be equiva- + lent to '1 / (2 meter)'. Defining Nonlinear Units Some unit conversions of interest are nonlinear; for example, tempera- @@ -1641,7 +1996,7 @@ for comparison. Without units, numerical values other than zero or plus or minus infinity for domain or range endpoints are meaningless, and accordingly they are not allowed. If you give other values without - units then the definition will be ignored and you will get an error + units, then the definition will be ignored and you will get an error message. Although the units, domain, and range specifications are optional, it's @@ -1916,7 +2271,7 @@ / 0.201168 Precision - The meaning of ``precision'' depends on the format type. With 'g' or + The meaning of "precision" depends on the format type. With 'g' or 'G', it specifies the number of significant digits (like the '--digits' option); with 'e', 'E', 'f', or 'F', it specifies the maximum number of digits to be shown after the decimal point. @@ -2026,17 +2381,17 @@ A conditional block of definitions in a units data file begins with either '!var' or '!varnot' following by an environment variable name - and then a space separated list of values. The leading '!' must - appear in the first column of a units data file, and the conditional - block is terminated by '!endvar'. Definitions in blocks beginning with - '!var' are executed only if the environment variable is exactly equal - to one of the listed values. Definitions in blocks beginning with - '!varnot' are executed only if the environment variable does not equal - any of the list values. + and then a space separated list of values. The leading '!' must appear + in the first column of a units data file, and the conditional block is + terminated by '!endvar'. Definitions in blocks beginning with '!var' + are executed only if the environment variable is exactly equal to one + of the listed values. Definitions in blocks beginning with '!varnot' + are executed only if the environment variable does not equal any of the + list values. The inch has long been a customary measure of length in many places. - The word comes from the latin uncia meaning ``one twelfth,'' referring - to its relationship with the foot. By the 20th century, the inch was + The word comes from the Latin uncia meaning "one twelfth," referring to + its relationship with the foot. By the 20th century, the inch was officially defined in English-speaking countries relative to the yard, but until 1959, the yard differed slightly among those countries. In France the customary inch, which was displaced in 1799 by the meter, @@ -2068,7 +2423,7 @@ When 'units' reads the above definitions it will check the environment variable 'INCH_UNIT' and load only the definitions for the appropriate section. If 'INCH_UNIT' is unset or is not set to one of the four val- - ues listed then 'units' will run the last block. In this case that + ues listed, then 'units' will run the last block. In this case that block uses the '!message' command to display a warning message. Alter- natively that block could set default values. @@ -2076,7 +2431,7 @@ the data file can use the '!set' command, which sets an environment variable only if it is not already set; these settings are only for the current 'units' invocation and do not persist. So if the example - above were preceded by '!set INCH_UNIT france' then this would make + above were preceded by '!set INCH_UNIT france', then this would make 'france' the default value for 'INCH_UNIT'. If the user had set the variable in the environment before invoking 'units', then 'units' would use the user's value. @@ -2105,7 +2460,7 @@ default setting comes last so that it only applies when 'INCH_UNIT' was not set by one of the other commands or by the user. - If the variable given after '!var' or '!varnot' is undefined then + If the variable given after '!var' or '!varnot' is undefined, then 'units' prints an error message and ignores the definitions that fol- low. Use '!set' to create defaults to prevent this situation from arising. The '-c' option only checks the definitions that are active @@ -2163,6 +2518,11 @@ option or the 'UNITSFILE' environment variable, and that loca- tion does not also contain the locale map file. + UNITS_SYSTEM + This environment variable is used in the standard data file to + select CGS measurement systems. Currently supported systems are + 'esu', 'emu', 'gauss[ian]', and 'si'. The default is 'si'. + DATA FILES The 'units' program uses two default data files: 'definitions.units' and 'currency.units'. The program can also use an optional personal @@ -2173,27 +2533,28 @@ On Unix-like systems, the data files are typically located in '/usr/share/units' if 'units' is provided with the operating system, or in '/usr/local/share/units' if 'units' is compiled from the source dis- - tribution. + tribution. Note that the currency file 'currency.units' is a symbolic + link to another location. - On systems running Microsoft Windows, the files may be in the same - locations if Unix-like commands are available, a Unix-like file struc- - ture is present (e.g., 'C:/usr/local'), and 'units' is compiled from - the source distribution. If Unix-like commands are not available, a - more common location is 'C:\Program Files (x86)\GNU\units' (for 64-bit + On systems running Microsoft Windows, the files may be in the same + locations if Unix-like commands are available, a Unix-like file struc- + ture is present (e.g., 'C:/usr/local'), and 'units' is compiled from + the source distribution. If Unix-like commands are not available, a + more common location is 'C:\Program Files (x86)\GNU\units' (for 64-bit Windows installations) or 'C:\Program Files\GNU\units' (for 32-bit installations). - If 'units' is obtained from the GNU Win32 Project + If 'units' is obtained from the GNU Win32 Project (http://gnuwin32.sourceforge.net/), the files are commonly in 'C:\Program Files\GnuWin32\share\units'. - If the default units data file is not an absolute pathname, 'units' - will look for the file in the directory that contains the 'units' pro- - gram; if the file is not found there, 'units' will look in a directory + If the default units data file is not an absolute pathname, 'units' + will look for the file in the directory that contains the 'units' pro- + gram; if the file is not found there, 'units' will look in a directory '../share/units' relative to the directory with the 'units' program. - You can determine the location of the files by running - 'units --version'. Running 'units --info' will give you additional + You can determine the location of the files by running + 'units --version'. Running 'units --info' will give you additional information about the files, how 'units' will attempt to find them, and the status of the related environment variables. @@ -2203,40 +2564,49 @@ U+007F); definitions using non-ASCII characters appear in blocks begin- ning with '!utf8' and ending with '!endutf8'. - When 'units' starts, it checks the locale to determine the character - set. If 'units' is compiled with Unicode support and definitions; oth- - erwise these definitions are ignored. When Unicode support is active, - 'units' will check every line of all of the units data files for - invalid or non-printing UTF-8 sequences; if such sequences occur, - 'units' ignores the entire line. In addition to checking validity, - 'units' determines the display width of non-ASCII characters to ensure - proper positioning of the pointer in some error messages and to align - columns for the 'search' and '?' commands. - - At present, 'units' does not support Unicode under Microsoft Windows. - The UTF-16 and UTF-32 encodings are not supported on any systems. - - If definitions that contain non-ASCII characters are added to a units - data file, those definitions should be enclosed within '!utf8' ... - '!endutf8' to ensure that they are only loaded when Unicode support is - available. As usual, the '!' must appear as the first character on - the line. As discussed in Units Data Files, it's usually best to put - such definitions in supplemental data files linked by an '!include' - command or in a personal units data file. - - When Unicode support is not active, 'units' makes no assumptions about - character encoding, except that characters in the range 00-7F hexadeci- - mal correspond to ASCII encoding. Non-ASCII characters are simply - sequences of bytes, and have no special meanings; for definitions in - supplementary units data files, you can use any encoding consistent - with this assumption. For example, if you wish to use non-ASCII char- - acters in definitions when running 'units' under Windows, you can use a - character set such as Windows ``ANSI'' (code page 1252 in the US and - Western Europe). You can even use UTF-8, though some messages may be - improperly aligned, and 'units' will not detect invalid UTF-8 - sequences. If you use UTF-8 encoding when Unicode support is not - active, you should place any definitions with non-ASCII characters out- - side '!utf8' ... '!endutf8' blocks--otherwise, they will be ignored. + The non-ASCII definitions are loaded only if the platform and the + locale support UTF-8. Platform support is determined when 'units' is + compiled; the locale is checked at every invocation of 'units'. To see + if your version of 'units' includes Unicode support, invoke the program + with the '--version' option. + + When Unicode support is available, 'units' checks every line within + UTF-8 blocks in all of the units data files for invalid or non-printing + UTF-8 sequences; if such sequences occur, 'units' ignores the entire + line. In addition to checking validity, 'units' determines the display + width of non-ASCII characters to ensure proper positioning of the + pointer in some error messages and to align columns for the 'search' + and '?' commands. + + As of early 2019, Microsoft Windows provides limited support for UTF-8 + in console applications, and accordingly, 'units' does not support Uni- + code on Windows. The UTF-16 and UTF-32 encodings are not supported on + any platforms. + + If Unicode support is available and definitions that contain non-ASCII + UTF-8 characters are added to a units data file, those definitions + should be enclosed within '!utf8' ... '!endutf8' to ensure that they + are only loaded when Unicode support is available. As usual, the '!' + must appear as the first character on the line. As discussed in Units + Data Files, it's usually best to put such definitions in supplemental + data files linked by an '!include' command or in a personal units data + file. + + When Unicode support is not available, 'units' makes no assumptions + about character encoding, except that characters in the range 00-7F + hexadecimal correspond to ASCII encoding. Non-ASCII characters are + simply sequences of bytes, and have no special meanings; for defini- + tions in supplementary units data files, you can use any encoding con- + sistent with this assumption. For example, if you wish to use non- + ASCII characters in definitions when running 'units' under Windows, you + can use a character set such as Windows "ANSI" (code page 1252 in the + US and Western Europe); if this is done, the console code page must be + set to the same encoding for the characters to display properly. You + can even use UTF-8, though some messages may be improperly aligned, and + 'units' will not detect invalid UTF-8 sequences. If you use UTF-8 + encoding when Unicode support is not available, you should place any + definitions with non-ASCII characters outside '!utf8' ... '!endutf8' + blocks--otherwise, they will be ignored. Typeset material other than code examples usually uses the Unicode minus (U+2212) rather than the ASCII hyphen-minus operator (U+002D) @@ -2257,7 +2627,7 @@ allow editing in the style of emacs. Of particular use with 'units' are the completion commands. - If you type a few characters and then hit ESC followed by '?' then + If you type a few characters and then hit ESC followed by '?', then 'units' will display a list of all the units that start with the char- acters typed. For example, if you type 'metr' and then request comple- tion, you will see something like this: @@ -2268,7 +2638,7 @@ metriccarat metricgrain metricquart metricyarncount You have: metr - If there is a unique way to complete a unitname, you can hit the TAB + If there is a unique way to complete a unit name, you can hit the TAB key and 'units' will provide the rest of the unit name. If 'units' beeps, it means that there is no unique completion. Pressing the TAB key a second time will print the list of all completions. @@ -2286,23 +2656,97 @@ to the history file upon exit. UPDATING CURRENCY EXCHANGE RATES - The units program includes currency exchange rates and prices for some - precious metals in the database. Of course, these values change over - time, sometimes very rapidly, and 'units' cannot provide real time val- - ues. To update the exchange rates run the 'units_cur', which rewrites - the files containing the currency rates, typically - '/usr/share/units/currency.units'. This program requires 'python', and - must be run with suitable permissions to write the file. To keep the - rates updated automatically, run it using a cron job on a Unix-like - system, or a similar scheduling program on a different system. Cur- - rency exchange rates are taken from Yahoo (http://finance.yahoo.com) - and precious metals pricing from Packetizer (www.packetizer.com). - These sites update once per day, so there is no benefit in running the - update script more often than daily. You can run 'units_cur' with a - filename specified on the command line and it will write the data to + The units program database includes currency exchange rates and prices + for some precious metals. Of course, these values change over time, + sometimes very rapidly, and 'units' cannot provide real-time values. + To update the exchange rates, run 'units_cur', which rewrites the file + containing the currency rates, typically '/var/lib/units/ + currency.units' or '/usr/local/com/units/currency.units' on a Unix-like + system or 'C:\Program Files (x86)\GNU\units\definitions.units' on a + Windows system. + + This program requires Python (https://www.python.org); either version 2 + or 3 will work. The program must be run with suitable permissions to + write the file. To keep the rates updated automatically, run it using + a cron job on a Unix-like system, or a similar scheduling program on a + different system. + + Reliable free sources of currency exchange rates have been annoyingly + ephemeral. The program currently supports several sources: + + * FloatRates (https://www/floatrates.com). The US dollar ('USD') is + the default base currency. You can change the base currency with + the '-b' option described below. Allowable base currencies are + listed on the FloatRates website. Exchange rates update daily. + + * The European Central Bank (https://www.ecb.europa.eu). The base + currency is always the euro ('EUR'). Exchange rates update daily. + This source offers a more limited list of currencies than the oth- + ers. + + * Fixer (https://fixer.io). Registration for a free API key is + required. With a free API key, base currency is the euro; exchange + rates are updated hourly, the service has a limit of 1,000 API + calls per month, and SSL encryption (https protocol) is not avail- + able. Most of these restrictions are eliminated or reduced with + paid plans. + + * open exchange rates (https://openexchangerates.org). Registration + for a free API key is required. With a free API key, the base cur- + rency is the US dollar; exchange rates are updated hourly, and + there is a limit of 1,000 API calls per month. Most of these + restrictions are eliminated or reduced with paid plans. + + The default source is FloatRates; you can select a different one using + '-s' option described below. + + Precious metals pricing is obtained from Packetizer (www.packe- + tizer.com). This site updates once per day. + + You invoke 'units_cur' like this: + + units_cur [options] [outfile] + + By default, the output is written to the default currency file + described above; this is usually what you want, because this is where + 'units' looks for the file. If you wish, you can specify a different + filename on the command line and 'units_cur' will write the data to that file. If you give '-' for the file it will write to standard out- put. + The following options are available: + + -h, --help + Print a summary of the options for 'units_cur'. + + -V, --version + Print the 'units_cur' version number. + + -v, --verbose + Give slightly more verbose output when attempting to update cur- + rency exchange rates. + + -s source, --source source + Specify the source for currency exchange rates; currently sup- + ported values are 'floatrates' (for FloatRates), 'eubank' (for + the European Central Bank), 'fixer' (for Fixer), and + 'openexchangerates' (for open exchange rates); the last two + require an API key to be given with the '-k' option. + + -b base, --base base + Set the base currency (when allowed by the site providing the + data). base should be a 3-letter ISO currency code, e.g., + 'USD'. The specified currency will be the primitive currency + unit used by 'units'. You may find it convenient to specify + your local currency. Conversions may be more accurate and you + will be able to convert to your currency by simply hitting Enter + at the 'You want:' prompt. This option is ignored if the source + does not allow specifying the base currency. (Currently only + floatrates supports this option.) + + -k key, --key key + Set the API key to key for sources that require it. + DATABASE COMMAND SYNTAX unit definition Define a regular unit. @@ -2339,7 +2783,12 @@ !message text Display text when the database is read unless the quiet option - ('-q') is enabled. + ('-q') is enabled. If you omit text, then units will display a + blank line. Messages will also appear in the log file. + + !prompt text + Prefix the 'You have:' prompt with the specified text. If you + omit text, then any existing prefix is canceled. !set variable value Sets the environment variable, variable, to the specified value @@ -2363,10 +2812,13 @@ space-separated value list. If envar is not set, 'units' prints an error message and ignores the block of definitions. -GNU FREE DOCUMENTATION LICENSE FILES /usr/local/share/units/definitions.units -- the standard units data file AUTHOR - 16 October 2017 UNITS(1) + units was written by Adrian Mariano + + + + 19 March 2019 UNITS(1) Binary files /tmp/tmp5EHtQ4/72Ux5uwBEZ/units-2.16/UnitsWin.pdf and /tmp/tmp5EHtQ4/0mofb4A4hK/units-2.19/UnitsWin.pdf differ diff -Nru units-2.16/UnitsWin.texinfo units-2.19/UnitsWin.texinfo --- units-2.16/UnitsWin.texinfo 2017-11-01 01:44:28.000000000 +0000 +++ units-2.19/UnitsWin.texinfo 2018-09-10 10:55:54.000000000 +0000 @@ -291,8 +291,8 @@ @end enumerate -@node Running the Updater -@unnumbered Running the Updater +@node Running the Currency Updater +@unnumbered Running the Currency Updater @node Updating from a Command Prompt @unnumberedsec Updating from a Command Prompt @@ -302,6 +302,11 @@ file by running @command{units_cur.py} from any instance of the Windows command prompt. +Reliable free sources of currency exchange rates have been annoyingly +ephemeral, sometimes causing update attempts to fail. Accordingly, +several different sources are now supported---see the units manual for +details. + @node Automatic Updates @unnumberedsec Automatic Updates