/usr.bin/units/units.1

https://bitbucket.org/freebsd/freebsd-head/ · Unknown · 183 lines · 179 code · 4 blank · 0 comment · 0 complexity · 3c2e07e46a9b84e26cb9ff83c3033a4f MD5 · raw file

  1. .\" $FreeBSD$
  2. .Dd July 14, 1993
  3. .Dt UNITS 1
  4. .Os
  5. .Sh NAME
  6. .Nm units
  7. .Nd conversion program
  8. .Sh SYNOPSIS
  9. .Nm
  10. .Op Fl f Ar filename
  11. .Op Fl qv
  12. .Op Ar from-unit to-unit
  13. .Sh OPTIONS
  14. The following options are available:
  15. .Bl -tag -width indent
  16. .It Fl f Ar filename
  17. Specify the name of the units data file to load.
  18. .It Fl q
  19. Suppress prompting of the user for units and the display of statistics
  20. about the number of units loaded.
  21. .It Fl v
  22. Print the version number.
  23. .It Ar from-unit to-unit
  24. Allow a single unit conversion to be done directly from the command
  25. line.
  26. The program will not print prompts.
  27. It will print out the
  28. result of the single specified conversion.
  29. .El
  30. .Sh DESCRIPTION
  31. The
  32. .Nm
  33. program converts quantities expressed in various scales to
  34. their equivalents in other scales.
  35. The
  36. .Nm
  37. program can only
  38. handle multiplicative or affine scale changes.
  39. It works interactively by prompting
  40. the user for input:
  41. .Bd -literal
  42. You have: meters
  43. You want: feet
  44. * 3.2808399
  45. / 0.3048
  46. You have: cm^3
  47. You want: gallons
  48. * 0.00026417205
  49. / 3785.4118
  50. You have: meters/s
  51. You want: furlongs/fortnight
  52. * 6012.8848
  53. / 0.00016630952
  54. You have: 1|2 inch
  55. You want: cm
  56. * 1.27
  57. / 0.78740157
  58. You have: 85 degF
  59. You want: degC
  60. 29.444444
  61. .Ed
  62. .Pp
  63. Powers of units can be specified using the '^' character as shown in
  64. the example, or by simple concatenation: 'cm3' is equivalent to 'cm^3'.
  65. Multiplication of units can be specified by using spaces, a dash or
  66. an asterisk.
  67. Division of units is indicated by the slash ('/').
  68. Note that multiplication has a higher precedence than division,
  69. so 'm/s/s' is the same as 'm/s^2' or 'm/s s'.
  70. Division of numbers
  71. must be indicated using the vertical bar ('|').
  72. To convert half a
  73. meter, you would write '1|2 meter'.
  74. If you write '1/2 meter' then the
  75. units program would interpret that as equivalent to '0.5/meter'.
  76. If you enter incompatible unit types, the units program will
  77. print a message indicating that the units are not conformable and
  78. it will display the reduced form for each unit:
  79. .Bd -literal
  80. You have: ergs/hour
  81. You want: fathoms kg^2 / day
  82. conformability error
  83. 2.7777778e-11 kg m^2 / sec^3
  84. 2.1166667e-05 kg^2 m / sec
  85. .Ed
  86. .Pp
  87. The conversion information is read from a units data file.
  88. The default
  89. file includes definitions for most familiar units, abbreviations and
  90. metric prefixes.
  91. Some constants of nature included are:
  92. .Pp
  93. .Bl -column -offset indent -compact "mercury"
  94. .It "pi ratio of circumference to diameter"
  95. .It "c speed of light"
  96. .It "e charge on an electron"
  97. .It "g acceleration of gravity"
  98. .It "force same as g"
  99. .It "mole Avogadro's number"
  100. .It "water pressure per unit height of water"
  101. .It "mercury pressure per unit height of mercury"
  102. .It "au astronomical unit"
  103. .El
  104. .Pp
  105. The unit 'pound' is a unit of mass.
  106. Compound names are run together
  107. so 'pound force' is a unit of force.
  108. The unit 'ounce' is also a unit
  109. of mass.
  110. The fluid ounce is 'floz'.
  111. British units that differ from
  112. their US counterparts are prefixed with 'br', and currency is prefixed
  113. with its country name: 'belgiumfranc', 'britainpound'.
  114. When searching
  115. for a unit, if the specified string does not appear exactly as a unit
  116. name, then
  117. .Nm
  118. will try to remove a trailing 's' or a
  119. trailing 'es' and check again for a match.
  120. .Pp
  121. To find out what units are available read the standard units file.
  122. If you want to add your own units you can supply your own file.
  123. A unit is specified on a single line by
  124. giving its name and an equivalence.
  125. Be careful to define
  126. new units in terms of old ones so that a reduction leads to the
  127. primitive units which are marked with '!' characters.
  128. The
  129. .Nm
  130. program will not detect infinite loops that could be caused
  131. by careless unit definitions.
  132. Comments in the unit definition file
  133. begin with a '/' character at the beginning of a line.
  134. .Pp
  135. Prefixes are defined in the same was as standard units, but with
  136. a trailing dash at the end of the prefix name.
  137. If a unit is not found
  138. even after removing trailing 's' or 'es', then it will be checked
  139. against the list of prefixes.
  140. Prefixes will be removed until a legal
  141. base unit is identified.
  142. .Pp
  143. Here is an example of a short units file that defines some basic
  144. units.
  145. .Pp
  146. .Bl -column -offset indent -compact "minute"
  147. .It "m !a!"
  148. .It "sec !b!"
  149. .It "micro- 1e-6"
  150. .It "minute 60 sec"
  151. .It "hour 60 min"
  152. .It "inch 0.0254 m"
  153. .It "ft 12 inches"
  154. .It "mile 5280 ft"
  155. .El
  156. .Sh FILES
  157. .Bl -tag -width /usr/share/misc/units.lib -compact
  158. .It Pa /usr/share/misc/units.lib
  159. the standard units library
  160. .El
  161. .Sh AUTHORS
  162. .An Adrian Mariano Aq adrian@cam.cornell.edu
  163. .Sh BUGS
  164. The effect of including a '/' in a prefix is surprising.
  165. .Pp
  166. Exponents entered by the user can be only one digit.
  167. You can work around this by multiplying several terms.
  168. .Pp
  169. The user must use | to indicate division of numbers and / to
  170. indicate division of symbols.
  171. This distinction should not
  172. be necessary.
  173. .Pp
  174. The program contains various arbitrary limits on the length
  175. of the units converted and on the length of the data file.
  176. .Pp
  177. The program should use a hash table to store units so that
  178. it does not take so long to load the units list and check
  179. for duplication.