Units for Android

This application serves as an Android interface to the standard GNU units program, which has been recompiled with the Android Native Development Kit. Thus, much of the original functionality of units is maintained.

The original GNU units was written by Adrian Mariano.

The Android version works much like standard units invoked in interactive mode. Enter expressions for your known values in the You have entry box, and put target conversion expressions in the You want entry box. Press the Convert button. Conversion and other information (formatted based on flags/options as described below) appear in the editable “Results” box.

Entry history: you can press your device’s Back key in the You have, You want, and Results boxes to cycle back through your entries. Press Back twice in rapid succession to make the “back” function behave as it ordinarily does. You can turn off this functionality via Preferences if you don’t like it. The application keeps track of your previous 100 entries in each of the entry boxes, and maintains this history even if you leave the application or turn off your phone.

Flags/Options: with some exceptions, many of the original command-line options are available in the Android version. These options can be changed using the Flag/Options settings under the Preferences menu. For simplicity, the Android version sets the --terse option initially by default. You can remove or change this option if it does not suit you.

Autocompletion: off by default, you can turn on autocompletion with the Autocomplete threshold preferences item. Select the number of characters entered that will trigger a drop-down list of recognized units of measures and functions beginning with those characters.

You can also enter search xxx (where xxx is some string of characters) in the You have box to search for units of measures and functions. For example, to search for units of measure that contain the string “amp”, enter search amp and then press Convert. The Results box will contain:

       abamp           abampere
       abampere        10 A
       amp             ampere
       ampere          A
       amphora         8 congii
       amphorae        amphora
       intamp          intampere
       intampere       0.999835 A
       statamp         statampere
       statampere      10 A cm / s c
       thermalampere   W/K


Share: this menu item allows you to select a sharing application (e.g., email, text message), and copy a units result to that application. The applications available for sharing results depend on what you have installed on your device.

You can specify custom units files using the -f command-line option (set in Preferences >Flags/Options). You can also edit and/or replace the units.dat file in its default directory (this location may vary based on your platform):


If you use the -f option, you have to specify the full path to where you installed your custom units file. For example, you could install your custom units file on your sdcard (a device’s optional memory card), and then use this file by including the following Preferences->Flags/Options:

     -f /mnt/sdcard/myunits.dat -f ""

(Note the use of the -f "" flag, which loads the default units file in addition to your custom units file – this is almost always what you want to do.)

If you edit or use your own custom unit file, you should check it (--check) using a non-Android version of units before use with the Android port.

A couple of custom data files are installed with the distribution as examples. Using

     -f med.dat -f ""

you can perform some medically-oriented conversions, for example, converting between “traditional” and SI units of measure for various lab values:

If you use

     -f fun.dat -f ""

you get access to some bonus definitions and conversions, for example, “2000 mockingbird = 2 kilomockingbird,” and others:

            You have:  1 paradigm
            You want:
            Results:   Definition: 4 nickels

            You have:  1 gigolo
            You want:  picolos
            Results:   1e+21 picolos

            You have:  2 megacycles
            You want:  bicycles
            Results:   1e6 bicycles

            You have:  1 megaphone
            You want:  microphones
            Results:   1e12 microphones

            You have:  1 milliHelen_Of_Troy
            You want:
	    Results:   Definition: 1 amount_of_face_that_can_launch_one_ship

(This units conversion file also allows use of the proposed hella- SI prefix for values of 10^27. Using this prefix, you can determine that “1 hellaHelen_Of_Troy” could launch 10^30 ships (“1000 hella ships”).

(Many of the conversions in gnuunits_fun.dat are adapted from the “Q Files, a subsidiary of Evil Mad Scientist Laboratories,” which in turn notes that the original information was taken from “The Bent of Tau Beta Pi, Spring 1988″).

Both med.dat and fun.dat are located in the default installation directories on your device, if you want to edit them:


Click here for source. The source is structured as a standard Eclipse project.

Alternative implementation
If this version of units for Android doesn’t meet you needs or if you want to try another Android implementation of units, consider Steve Pomeroy’s Android Units, which has a user interface tailored to GNU units. It’s also based on GNU units 1.88.

License and warranty:
You can redistribute Units for Android 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.

Comments are closed.