Convert non-metric units to metric
Find a file
2023-06-01 19:58:18 +03:00
src Make unit constants const in conversion.rs 2023-06-01 19:58:18 +03:00
.gitignore First commit 2023-05-13 17:50:18 +03:00
Cargo.lock First commit 2023-05-13 17:50:18 +03:00
Cargo.toml Add CC0 license 2023-05-28 23:24:05 +03:00
CC0 Add CC0 license 2023-05-28 23:24:05 +03:00
README.md Run a REPL if no arguments are given 2023-06-01 19:39:48 +03:00

Metrify

Metrify is a tool for converting commonly-used non-metric units to metric.

Usage

Simplest way to use metrify is to invoke it with an expression in terms of non-metric units as its arguments:

metrify 1.4 short tons

The expression can contain several number + unit sequences, which are summed together if the units are compatible:

metrify 58″
metrify 1 acre 15 square feet

You can also invoke metrify without arguments, in which case it will give you a prompt to type the expression into. Press ^D to exit.

Result display

Metrify will pick the appropriate prefix for the given result and unit automatically. The value is rounded so that results <1 have 4 digits, <10 3 digits, <100 2 digits, <1000 1 digit and ≥1000 no digits after the decimal point. The digits before the decimal point are grouped into groups of three.

0.4929 ml
1.609 km
28.35 g
907.2 kg
28 317 cm³

Supported units

Length units based on the international yard

  • inch (in)
  • foot (ft)
  • yard (yd)
  • mile (mi)

Mass units based on the international pound

  • ounce (oz)
  • pound (lb)
  • stone (st)
  • short ton
  • long ton

Temperature

  • degrees Fahrenheit (°F)

Area units based on the international yard

  • square inch (in²)
  • square foot (ft²)
  • square yard (yd²)
  • acre (ac)
  • square mile (mi²)

Volume units based on the international yard

  • cubic inch (in³)
  • cubic foot (ft³)
  • cubic yard (yd³)

Imperial fluid volume units

  • imperial fluid ounce (imp fl oz)
  • imperial pint (imp pt)
  • imperial quart (imp qt)
  • imperial gallon (imp gal)

US customary fluid volume units

  • US teaspoon (tsp)
  • US tablespoon (tbsp)
  • US fluid ounce (us fl oz)
  • US cup (cup)
  • US pint (us pt)
  • US quart (us qt)
  • US gallon (us gal)

Why should I use metrify instead of units(1)?

Metrify is more special-purpose than units(1), which allows it to present the user a nicer interface for the purposes it does support. For example with metrify you do not need to explicitly tell it the unit you are converting to, because due to its requirements (conversion is always from non-metric to metric) it can automatically pick the correct one.

Why should I use units(1) instead of metrify?

units(1) includes many more units than covered by metrify, in addition to allowing other conversions than non-metric to metric. It can also be used for calculations involving units, which metrify does not handle outside of addition.

Building and installation

You can build and test out metrify with cargo run. If you want to install it locally, you can use cargo install --path . in the source directory.

License

Metrify is under Creative Commons Zero 1.0.