back to index

Unit Calculator

Mon Oct 04 2004, 8:33 PM

Purpose

A simple program for converting units between representations. Intended to work as a quick tool.

Usage

Usage: ucalc      for conversion

or ucalc /units [typedef] for list of unit identificators or ucalc /units ? for list of unit typedefs

Example:

[machine:/~]$ ucalc 100 mi

Input: length:mile 100 mi

Results: meter 160.935 km meter 160935 m foot 528002 ft mile 100 mi nav.mile 86.8417 nmi versta 150.858 vst geogr.mile 21.6894 gmi li 321.87 li zhang 48280.5 zhang chi 482805 chi

[machine:/~]$ ucalc 100 MHz

Input: freq:Hertz 100 MHz

Results: Hertz 100 MHz wavelength:meter 2.99792 m.w

[machine:/~]$ ucalc 100 MJ

Input: energy:joule 100 MJ

Results: joule 1e+08 J joule 100 MJ watt-hour 27.7732 kWh Brit.Therm.Unit 94781.6 Btu gram-centimeter 101.968 g/cm horsepower-hour 37.2578 HP/h therm-EU 0.947813 therm therm-US 0.948043 therm.us thermie 23.892 thermie

Compilation

For a commandline utility:
cc -o ucalc ucalc.c

For CGI:
(Program then takes input from $QUERY_STRING instead from arguments, and its output is formatted in HTML.)
cc -o ucalc.cgi ucalc.c

Files

ucalc.c - the source itself
ucalc.ini - the file with the constants declaration, needs to be placed to

If you have any comments or questions about the topic, please let me know here:
Your name:
Your email:
Spambait
Leave this empty!
Only spambots enter stuff here.
Feedback: