forth/yuko-notes.org

156 lines
6.2 KiB
Org Mode
Raw Permalink Normal View History

2022-02-08 13:14:44 +00:00
Yuko Development Notes
* Purpose
To replace Cora Phyco with unit conversion system using primarily
integer arithmetic.
* Style
Instead of Cora Phyco-style
conversion-constants-with-universal-converter, use more conventional
function-per-unit-pair style. Results not prnted but left on top of
stack for user to print or use in further calculation.
Reduce supported units to minimum necessary to reduce number of
functions to program.
Reduce all ratios to lowest terms to reduce chance of overflow.
* Conversion Ratios
The statement "The ratio of unit A to unit B is x:y" means that for a
given quantity, the magnitude of the quantity measured in unit A and
the magnitude of the same quantity measured in unit B are in the
ratio x:y. (NOT the ratio of the quantities of 1 unit of A and 1 unit
of B.)
** Linear measure
Units: mm, in, ft, m, km, mi
*** Defined ratios
| in:mm | 10:254 = 5:127 |
| m:mm | 1:1000 |
| km:m | 1:1000 |
| ft:in | 1:12 |
| mi:ft | 1:5280 |
*** Derived ratios
| km:mm | 1:1000000 |
| mi:in | 1:63360 |
| ft:mm | 5:1524 |
| mi:mm | 1:1609344 |
| m:in | 127:5000 |
| km:in | 127:5000000 |
| m:ft | 381:1250 |
| km:ft | 381:1250000 |
| mi:m | 5000:8047863 |
| mi:km | 5000000:8047863 |
** Time
Units: s, min, hr, day, yr
| 60 s = 1 min | 60/1 | min>s | 60 * |
| | | s>min | 60 / |
| 3600 s = 1 hr | 3600/1 | hr>s | 3600 * |
| | | s>hr | 3600 / |
| 86400 s = 1 day | 86400/1 | day>s | 86400 * |
| | | s>day | 86400 / |
| 30780000 s = 1 yr | 30780000/1 | yr>s | 30780000 * |
| | | s>yr | 30780000 / |
| 60 min = 1 hr | 60/1 | hr>min | 60 * |
| | | min>hr | 60 / |
| 1440 min = 1 day | 1440/1 | day>min | 1440 * |
| | | min>day | 1440 / |
| 24 hr = 1 day | 24/1 | day>hr | 24 * |
| | | hr>day | 24 / |
| 513000 min = 1 yr | 513000/1 | yr>min | 513000 * |
| | | min>yr | 513000 / |
| 4 yr = 1425 day | | | |
| | s | min | hr | day | yr |
|-----+---------+----------+--------+---------+----------|
| s | - | 60:1 | 3600:1 | 86400:1 | X |
| min | 1:60 | - | 60:1 | 1440:1 | 525960:1 |
| hr | 1:3600 | 1:60 | - | 24:1 | 8766:1 |
| day | 1:86400 | 1:1440 | 1:24 | - | 1461:4 |
| yr | X | 1:525960 | 1:8766 | 4:1461 | - |
| s>min | 60 / | | min>s | 60 * |
| s>hr | 3600 / | | hr>s | 3600 * |
| s>day | 86400 / | | day>s | 86400 * |
| min>hr | 60 / | | hr>min | 60 * |
| min>day | 1440 / | | day>min | 1440 * |
| min>yr | 525960 / | | yr>min | 525960 * |
| hr>day | 24 / | | day>hr | 24 * |
| hr>yr | 8766 / | | yr>hr | 8766 * |
| day>yr | 4 1461 */ | | yr>day | 1461 4 */ |
** Volume
ML milliliter L liter
TSP teaspoon TBSP tablespoon CUP FLOZ fluid ounce
PT pint QT quart GAL gallon
| 1000 ml = 1 l | 1000:1 |
| 3 tsp = 1 tbsp | 3:1 |
| 2 tbsp = 1 fl oz | 2:1 |
| 48 tsp = 1 cup | 48:1 |
| 8 fl oz = 1 cup | 8:1 |
| 2 cup = 1 pt | 2:1 |
| 2 pt = 1 qt | 2:1 |
| 4 qt = 1 gal | 4:1 |
| 3785.41784 ml = 1 gal | 378541784:100000 |
| | 47317723:12500 |
| (4.93 ml = 1 tsp) | |
| | ml | tsp | tbsp | fl oz | cup | pt | qt | l | gal |
| ml | - | 47317723 | 47317723 | 47317723 | 47317723 | 47317723 | 47317723 | 1000:1 | 47317723 |
| | | :9600000 | :3200000 | :1600000 | :200000 | :100000 | :50000 | | :12500 |
| tsp | 9600000: | - | 3:1 | 6:1 | 48:1 | 96:1 | 192:1 | 9600000000 | 768:1 |
| | 47317723 | | | | | | | :47317723 | |
| tbsp | 3200000: | 1:3 | - | 2:1 | 16:1 | 32:1 | 64:1 | 3200000000 | 256:1 |
| | 47317723 | | | | | | | :47317723 | |
| fl oz | 1600000: | 1:6 | 1:2 | - | 8:1 | 16:1 | 32:1 | 1600000000 | 128:1 |
| | 47317723 | | | | | | | :47317723 | |
| cup | 200000: | 1:48 | 1:16 | 1:8 | - | 2:1 | 4:1 | 200000000 | 16:1 |
| | 47317723 | | | | | | | :47317723 | |
| pt | 100000: | 1:96 | 1:32 | 1:16 | 1:2 | - | 2:1 | 100000000 | 8:1 |
| | 47317723 | | | | | | | :47317723 | |
| qt | 50000: | 1:192 | 1:64 | 1:32 | 1:4 | 1:2 | - | 50000000 | 4:1 |
| | 47317723 | | | | | | | :47317723 | |
| l | 1:1000 | 47317723: | 47317723: | 47317723: | 47317723: | 47317723: | 47317723: | - | 47317723: |
| | | 9600000000 | 3200000000 | 1600000000 | 200000000 | 100000000 | 50000000 | | 12500000 |
| gal | 12500: | 1:768 | 1:256 | 1:128 | 1:16 | 1:8 | 1:4 | 12500000: | - |
| | 47317723 | | | | | | | 47317723 | |
* Double-precision division
dn = nl + m*nh
dn / d = (nl + m*nh)/d
= nl/d + m*nh/d
: dn/ ( d n1 -- n2 ) tuck / rot rot / swap d>s ;
(Thought I would need this for converting between seconds and years,
but not so.)