[BACK]Return to units.1 CVS log [TXT][DIR] Up to [local] / src / usr.bin / units

Annotation of src/usr.bin/units/units.1, Revision 1.15

1.15    ! jmc         1: .\" $OpenBSD: units.1,v 1.14 2003/02/18 07:57:49 jmc Exp $
1.4       deraadt     2: .\" converted to new format by deraadt@openbsd.org
1.14      jmc         3: .\"
                      4: .\" Copyright (c) 1993 by Adrian Mariano (adrian@cam.cornell.edu)
                      5: .\"
                      6: .\" Redistribution and use in source and binary forms, with or without
                      7: .\" modification, are permitted provided that the following conditions
                      8: .\" are met:
                      9: .\" 1. Redistributions of source code must retain the above copyright
                     10: .\"    notice, this list of conditions and the following disclaimer.
                     11: .\" 2. The name of the author may not be used to endorse or promote products
                     12: .\"    derived from this software without specific prior written permission.
                     13: .\" Disclaimer:  This software is provided by the author "as is".  The author
                     14: .\" shall not be liable for any damages caused in any way by this software.
                     15: .\"
                     16: .\" I would appreciate (though I do not require) receiving a copy of any
                     17: .\" improvements you might make to this program.
1.15    ! jmc        18: .\"
1.4       deraadt    19: .Dd July 14, 1993
                     20: .Dt UNITS 1
                     21: .Os
                     22: .Sh NAME
1.5       deraadt    23: .Nm units
1.4       deraadt    24: .Nd conversion program
                     25: .Sh SYNOPSIS
1.7       aaron      26: .Nm units
1.4       deraadt    27: .Op Fl f Ar filename
                     28: .Op Fl q
                     29: .Op Fl v
1.8       aaron      30: .Ar from-unit
1.4       deraadt    31: .Ar to-unit
                     32: .Sh DESCRIPTION
1.10      aaron      33: The
                     34: .Nm
1.11      pjanzen    35: program converts quantities expressed in various scales to
1.10      aaron      36: their equivalents in other scales.
                     37: The
                     38: .Nm
                     39: program can only handle multiplicative scale changes.
                     40: It cannot convert Celsius
                     41: to Fahrenheit, for example.
1.11      pjanzen    42: It also does not handle logarithmic units such as bels.
1.10      aaron      43: It works interactively by prompting the user for input:
1.4       deraadt    44: .Pp
1.15    ! jmc        45: .Bd -literal -offset indent
        !            46: You have: meters
        !            47: You want: feet
        !            48:         * 3.2808399
        !            49:         / 0.3048
1.1       deraadt    50:
1.15    ! jmc        51: You have: cm^3
        !            52: You want: gallons
        !            53:         * 0.00026417205
        !            54:         / 3785.4118
        !            55: .Ed
1.13      pjanzen    56: .Pp
                     57: The
                     58: .Nm
                     59: program can handle numbers as well:
                     60: .Pp
1.15    ! jmc        61: .Bd -literal -offset indent
        !            62: You have: 60 miles/hr
        !            63: You want: km/hr
        !            64:         * 96.56064
        !            65:         / 0.010356187
1.13      pjanzen    66:
1.15    ! jmc        67: You have: 5 austriaschilling
        !            68: You want: 100 italylira
        !            69:         * 7.0357114
        !            70:         / 0.14213204
        !            71: .Ed
1.13      pjanzen    72: .Pp
                     73: In other words, 60 miles per hour is about 96.6 km/hr, and 5 Austrian
                     74: Schillings will get you seven 100-Lira coins.
1.4       deraadt    75: .Pp
1.10      aaron      76: The options are as follows:
                     77: .Bl -tag -width Ds
                     78: .It Fl f Ar filename
                     79: Specifies the name of the units data file to load.
                     80: .It Fl q
                     81: Suppresses prompting of the user for units and the display of statistics
                     82: about the number of units loaded.
                     83: .It Fl v
                     84: Prints the version number.
                     85: .It Ar from-unit Ar to-unit
                     86: Allows a single unit conversion to be done directly from the command line.
                     87: No prompting will occur.
                     88: The units program will print out
                     89: only the result of this single conversion.
                     90: .El
                     91: .Pp
1.8       aaron      92: Powers of units can be specified using the
                     93: .Ql ^
                     94: character as shown in
                     95: the example, or by simple concatenation:
1.9       pjanzen    96: .Sq cm3
1.8       aaron      97: is equivalent to
1.9       pjanzen    98: .Sq cm^3 .
1.1       deraadt    99: Multiplication of units can be specified by using spaces, a dash or
1.10      aaron     100: an asterisk.
                    101: Division of units is indicated by the slash
1.8       aaron     102: .Pq Ql / .
                    103: Note that multiplication has a higher precedence than division, so
1.9       pjanzen   104: .Sq m/s/s
1.8       aaron     105: is the same as
1.9       pjanzen   106: .Sq m/s^2
1.8       aaron     107: or
1.9       pjanzen   108: .Sq m/s s .
1.1       deraadt   109: If the user enters incompatible unit types, the units program will
                    110: print a message indicating that the units are not conformable and
                    111: it will display the reduced form for each unit:
1.4       deraadt   112: .Pp
1.15    ! jmc       113: .Bd -literal -offset indent
        !           114: You have: ergs/hour
        !           115: You want: fathoms kg^2 / day
        !           116: conformability error
        !           117:         2.7777778e-11 kg m^2 / sec^3
        !           118:         2.1166667e-05 kg^2 m / sec
        !           119: .Ed
1.4       deraadt   120: .Pp
1.10      aaron     121: The conversion information is read from a units data file.
                    122: The default file includes definitions for most familiar units,
                    123: abbreviations and metric prefixes.
                    124: Some constants of nature included are:
1.4       deraadt   125: .Bl -tag -width mercury
                    126: .It pi
                    127: ratio of circumference to diameter
                    128: .It c
                    129: speed of light
                    130: .It e
                    131: charge on an electron
                    132: .It g
                    133: acceleration of gravity
                    134: .It force
                    135: same as g
                    136: .It mole
                    137: Avogadro's number
                    138: .It water
1.9       pjanzen   139: pressure per unit height of water (at 4 C)
1.4       deraadt   140: .It mercury
                    141: pressure per unit height of mercury
1.9       pjanzen   142: .It ao
                    143: Bohr radius
                    144: .It AU
1.4       deraadt   145: astronomical unit
                    146: .El
                    147: .Pp
1.9       pjanzen   148: .Sq Pound
1.10      aaron     149: is a unit of mass.
                    150: Compound names are run together so
1.9       pjanzen   151: .Sq poundforce
1.10      aaron     152: is a unit of force.
                    153: British units that differ from their US counterparts are prefixed with
1.9       pjanzen   154: .Sq br ,
                    155: and currency is prefixed with its country name:
                    156: .Sq belgiumfranc ,
                    157: .Sq britainpound .
                    158: When searching for
1.1       deraadt   159: a unit, if the specified string does not appear exactly as a unit
1.9       pjanzen   160: name, then the units program will try to remove a trailing
                    161: .Sq s
                    162: or a trailing
                    163: .Sq es
                    164: and check again for a match.
1.4       deraadt   165: .Pp
1.1       deraadt   166: All of these definitions can be read in the standard units file, or you
1.10      aaron     167: can supply your own file.
                    168: A unit is specified on a single line by
                    169: giving its name and an equivalence.
                    170: One should be careful to define
1.1       deraadt   171: new units in terms of old ones so that a reduction leads to the
1.8       aaron     172: primitive units which are marked with
                    173: .Ql !
                    174: characters.
1.1       deraadt   175: The units program will not detect infinite loops that could be caused
                    176: by careless unit definitions.
1.4       deraadt   177: .Pp
1.8       aaron     178: Prefixes are defined in the same way as standard units, but with
1.10      aaron     179: a trailing dash at the end of the prefix name.
                    180: Prefixes are applied
1.9       pjanzen   181: after the longest matching unit name is found; for example,
                    182: .Dq nmile
                    183: is taken to be a nautical mile rather than a nanomile.
1.12      aaron     184: .Sh FILES
                    185: .Bl -tag -width /usr/share/misc/units.lib
                    186: .It Pa /usr/share/misc/units.lib
                    187: the standard units library
                    188: .El
                    189: .Sh AUTHORS
                    190: Adrian Mariano (adrian@cam.cornell.edu or mariano@geom.umn.edu)
1.4       deraadt   191: .Sh BUGS
1.8       aaron     192: The effect of including a
                    193: .Ql /
                    194: in a prefix is surprising.
1.4       deraadt   195: .Pp
1.9       pjanzen   196: Exponents of units entered by the user can be only one digit.
1.1       deraadt   197: You can work around this by multiplying several terms.
1.4       deraadt   198: .Pp
1.10      aaron     199: The user must use
                    200: .Ql |
                    201: to indicate division of numbers and
                    202: .Ql /
                    203: to indicate division of symbols.
                    204: This distinction should not be necessary.
1.9       pjanzen   205: .Pp
                    206: Prefixes specified without a unit are treated as dimensionless quantities.
                    207: This can lead to confusion when some prefixes are also defined as units
1.10      aaron     208: (e.g., m).
                    209: For example, Tera- / Giga- is 1000, but one Tesla (T) is 10,000
1.9       pjanzen   210: Gauss (G).
                    211: .Pp
                    212: Some non-SI units have multiple definitions (e.g, barrel, calorie) and
1.10      aaron     213: others have changed over time (e.g., cubit).
                    214: In particular, monetary values fluctuate.
1.4       deraadt   215: .Pp
1.1       deraadt   216: The program contains various arbitrary limits on the length
                    217: of the units converted and on the length of the data file.
1.4       deraadt   218: .Pp
1.1       deraadt   219: The program should use a hash table to store units so that
                    220: it doesn't take so long to load the units list and check
1.8       aaron     221: for duplication.