(42S, Free42) Unit Conversion Suite
By Dave Britten

This is an adaptation of the UNITS menu from the 48. Obviously the 42S doesn't have unit-based calculation like the 48, so these are strictly numeric conversions. The attached program is in raw format.

Usage is very simple; run CONV, then choose a unit category from the menu. The unit menus work pretty much like any solver menu: enter a value, press a menu key, then press another menu key for the unit you want to convert to. Continue pressing menu keys to convert to other units. Note that there's no checking of unit consistency, so the program won't stop you from doing something zany like converting between cm and lb.

Conversion constants were obtained from my 48SX, by converting 1 of each unit to its corresponding value in the base unit for any category (usually the first one in the menu). Only the display precision was used; I didn't attempt to pry out the internal guard digits. The program was tested by converting through all units within a menu and comparing results while doing the same on my 48SX.

Some notable changes from the 48 units:
-Hz was removed from the Time menu, as it's really just shorthand for 1/s (and loses usefulness without true composite units).
-YrCal (365 days) was added to the Time menu, and Yr changed to YrSol (value unchanged).
-ga was removed from the Speed menu. In its place is a new Accel menu that compensates for the lack of composite units, and which contains m/s^2, ft/s^2, grav, and gal (the latter two taken from the Prime).
-Btu/h was added to the Power menu.
-cmH2O was added to the Press menu.
-Elec, Angl, Light, Rad, and Visc unit menus have been omitted, mostly for reasons of lacking a true unit calculation system.

There's a decent conversion program already available with Free42, but there are a couple of things that bother me about it: there's very little code reuse, so each unit conversion has a bunch of repeated code and the conversion factors are entered twice, and it's somewhat fragile in its use of the Y register to hold the underlying unit value. It also makes use of flag 1 in a way I can't really figure out what it's meant to do.

I set out to replicate the layout of the unit menus from my 48 in a way that only requires 6 lines of code to add a new conversion (2 for the menu entry, 4 for the conversion). If you're missing any exotic ones, it's easy to extend the program.

You're free to do whatever you like with this code.

UPDATE Oct. 9, 2018 - I added a BYTES menu for converting between different bit/byte units with prefixes up to peta-. There's also WORD/DWORD/QWORD, with a configurable word size (default is 32 bits). If you need to work with nybbles, set the word size to 4, and just use WORD. You can choose whether the magnitude prefixes are treated as powers of 2 (the proper way) or powers of 10 (preferred by hard disk salespeople). There's also a 4th page with some rather special-purpose units I occasionally use: SQL Server pages and extents, Nintendo 3DS "blocks", and Commodore 64 1541 disk "blocks". You can trim out this page, or replace the entries with units more appropriate for your work.

UPDATE May 3, 2019 - I found one or two obscure conversion factors that were incorrect and fixed them. Also, this version takes advantage of flag 64 (which I believe is exclusive to the DM42) to provide a feature from the 19BII: if you press Shift+menu key, the input value will be added to a running total. For example, if you want to add 2 feet to 35 cm and convert the result to meters:

2 ["FEET"] 35 [SHIFT] ["CM"] ["M"]

The input value will be displayed with a "+" prefix to indicate this accumulation is taking place.