|
root / base / usr / src / cmd / units
units Plain Text 1167 lines 21.2 KB
   1
   2
   3
   4
   5
   6
   7
   8
   9
  10
  11
  12
  13
  14
  15
  16
  17
  18
  19
  20
  21
  22
  23
  24
  25
  26
  27
  28
  29
  30
  31
  32
  33
  34
  35
  36
  37
  38
  39
  40
  41
  42
  43
  44
  45
  46
  47
  48
  49
  50
  51
  52
  53
  54
  55
  56
  57
  58
  59
  60
  61
  62
  63
  64
  65
  66
  67
  68
  69
  70
  71
  72
  73
  74
  75
  76
  77
  78
  79
  80
  81
  82
  83
  84
  85
  86
  87
  88
  89
  90
  91
  92
  93
  94
  95
  96
  97
  98
  99
 100
 101
 102
 103
 104
 105
 106
 107
 108
 109
 110
 111
 112
 113
 114
 115
 116
 117
 118
 119
 120
 121
 122
 123
 124
 125
 126
 127
 128
 129
 130
 131
 132
 133
 134
 135
 136
 137
 138
 139
 140
 141
 142
 143
 144
 145
 146
 147
 148
 149
 150
 151
 152
 153
 154
 155
 156
 157
 158
 159
 160
 161
 162
 163
 164
 165
 166
 167
 168
 169
 170
 171
 172
 173
 174
 175
 176
 177
 178
 179
 180
 181
 182
 183
 184
 185
 186
 187
 188
 189
 190
 191
 192
 193
 194
 195
 196
 197
 198
 199
 200
 201
 202
 203
 204
 205
 206
 207
 208
 209
 210
 211
 212
 213
 214
 215
 216
 217
 218
 219
 220
 221
 222
 223
 224
 225
 226
 227
 228
 229
 230
 231
 232
 233
 234
 235
 236
 237
 238
 239
 240
 241
 242
 243
 244
 245
 246
 247
 248
 249
 250
 251
 252
 253
 254
 255
 256
 257
 258
 259
 260
 261
 262
 263
 264
 265
 266
 267
 268
 269
 270
 271
 272
 273
 274
 275
 276
 277
 278
 279
 280
 281
 282
 283
 284
 285
 286
 287
 288
 289
 290
 291
 292
 293
 294
 295
 296
 297
 298
 299
 300
 301
 302
 303
 304
 305
 306
 307
 308
 309
 310
 311
 312
 313
 314
 315
 316
 317
 318
 319
 320
 321
 322
 323
 324
 325
 326
 327
 328
 329
 330
 331
 332
 333
 334
 335
 336
 337
 338
 339
 340
 341
 342
 343
 344
 345
 346
 347
 348
 349
 350
 351
 352
 353
 354
 355
 356
 357
 358
 359
 360
 361
 362
 363
 364
 365
 366
 367
 368
 369
 370
 371
 372
 373
 374
 375
 376
 377
 378
 379
 380
 381
 382
 383
 384
 385
 386
 387
 388
 389
 390
 391
 392
 393
 394
 395
 396
 397
 398
 399
 400
 401
 402
 403
 404
 405
 406
 407
 408
 409
 410
 411
 412
 413
 414
 415
 416
 417
 418
 419
 420
 421
 422
 423
 424
 425
 426
 427
 428
 429
 430
 431
 432
 433
 434
 435
 436
 437
 438
 439
 440
 441
 442
 443
 444
 445
 446
 447
 448
 449
 450
 451
 452
 453
 454
 455
 456
 457
 458
 459
 460
 461
 462
 463
 464
 465
 466
 467
 468
 469
 470
 471
 472
 473
 474
 475
 476
 477
 478
 479
 480
 481
 482
 483
 484
 485
 486
 487
 488
 489
 490
 491
 492
 493
 494
 495
 496
 497
 498
 499
 500
 501
 502
 503
 504
 505
 506
 507
 508
 509
 510
 511
 512
 513
 514
 515
 516
 517
 518
 519
 520
 521
 522
 523
 524
 525
 526
 527
 528
 529
 530
 531
 532
 533
 534
 535
 536
 537
 538
 539
 540
 541
 542
 543
 544
 545
 546
 547
 548
 549
 550
 551
 552
 553
 554
 555
 556
 557
 558
 559
 560
 561
 562
 563
 564
 565
 566
 567
 568
 569
 570
 571
 572
 573
 574
 575
 576
 577
 578
 579
 580
 581
 582
 583
 584
 585
 586
 587
 588
 589
 590
 591
 592
 593
 594
 595
 596
 597
 598
 599
 600
 601
 602
 603
 604
 605
 606
 607
 608
 609
 610
 611
 612
 613
 614
 615
 616
 617
 618
 619
 620
 621
 622
 623
 624
 625
 626
 627
 628
 629
 630
 631
 632
 633
 634
 635
 636
 637
 638
 639
 640
 641
 642
 643
 644
 645
 646
 647
 648
 649
 650
 651
 652
 653
 654
 655
 656
 657
 658
 659
 660
 661
 662
 663
 664
 665
 666
 667
 668
 669
 670
 671
 672
 673
 674
 675
 676
 677
 678
 679
 680
 681
 682
 683
 684
 685
 686
 687
 688
 689
 690
 691
 692
 693
 694
 695
 696
 697
 698
 699
 700
 701
 702
 703
 704
 705
 706
 707
 708
 709
 710
 711
 712
 713
 714
 715
 716
 717
 718
 719
 720
 721
 722
 723
 724
 725
 726
 727
 728
 729
 730
 731
 732
 733
 734
 735
 736
 737
 738
 739
 740
 741
 742
 743
 744
 745
 746
 747
 748
 749
 750
 751
 752
 753
 754
 755
 756
 757
 758
 759
 760
 761
 762
 763
 764
 765
 766
 767
 768
 769
 770
 771
 772
 773
 774
 775
 776
 777
 778
 779
 780
 781
 782
 783
 784
 785
 786
 787
 788
 789
 790
 791
 792
 793
 794
 795
 796
 797
 798
 799
 800
 801
 802
 803
 804
 805
 806
 807
 808
 809
 810
 811
 812
 813
 814
 815
 816
 817
 818
 819
 820
 821
 822
 823
 824
 825
 826
 827
 828
 829
 830
 831
 832
 833
 834
 835
 836
 837
 838
 839
 840
 841
 842
 843
 844
 845
 846
 847
 848
 849
 850
 851
 852
 853
 854
 855
 856
 857
 858
 859
 860
 861
 862
 863
 864
 865
 866
 867
 868
 869
 870
 871
 872
 873
 874
 875
 876
 877
 878
 879
 880
 881
 882
 883
 884
 885
 886
 887
 888
 889
 890
 891
 892
 893
 894
 895
 896
 897
 898
 899
 900
 901
 902
 903
 904
 905
 906
 907
 908
 909
 910
 911
 912
 913
 914
 915
 916
 917
 918
 919
 920
 921
 922
 923
 924
 925
 926
 927
 928
 929
 930
 931
 932
 933
 934
 935
 936
 937
 938
 939
 940
 941
 942
 943
 944
 945
 946
 947
 948
 949
 950
 951
 952
 953
 954
 955
 956
 957
 958
 959
 960
 961
 962
 963
 964
 965
 966
 967
 968
 969
 970
 971
 972
 973
 974
 975
 976
 977
 978
 979
 980
 981
 982
 983
 984
 985
 986
 987
 988
 989
 990
 991
 992
 993
 994
 995
 996
 997
 998
 999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
#
# CDDL HEADER START
#
# The contents of this file are subject to the terms of the
# Common Development and Distribution License, Version 1.0 only
# (the "License").  You may not use this file except in compliance
# with the License.
#
# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
# or http://www.opensolaris.org/os/licensing.
# See the License for the specific language governing permissions
# and limitations under the License.
#
# When distributing Covered Code, include this CDDL HEADER in each
# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
# If applicable, add the following below this CDDL HEADER, with the
# fields enclosed by brackets "[]" replaced with your own identifying
# information: Portions Copyright [yyyy] [name of copyright owner]
#
# CDDL HEADER END
#
#
# Copyright (c) 1989 by Sun Microsystems, Inc.
#
# Copyright (c) 2018, Joyent, Inc.

PROG= units
UNITTAB=unittab

include ../Makefile.cmd

CERRWARN += -Wno-parentheses
CERRWARN += -Wno-implicit-function-declaration

# not linted
SMATCH=off

LIBUNITTAB= $(UNITTAB:%=$(ROOTSHLIB)/%)
$(LIBUNITTAB) :	FILEMODE =	$(LIBFILEMODE)

.KEEP_STATE:

all: $(PROG) unittab

install: all $(ROOTPROG) $(LIBUNITTAB)

clean:

lint:	lint_PROG

include ../Makefile.targ
Copyright (c) 1980 Regents of the University of California.  
All rights reserved.

Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are
met:

    1. Redistributions of source code must retain the above copyright
       notice, this list of conditions and the following disclaimer.
    2. Redistributions in binary form must reproduce the above
       copyright notice, this list of conditions and the following
       disclaimer in the documentation and/or other materials provided
       with the distribution.
    3. All advertising materials mentioning features or use of this
       software must display the following acknowledgement:
           This product includes software developed by the University
           of California, Berkeley and its contributors.
    4. Neither the name of the University nor the names of its
       contributors may be used to endorse or promote products derived
       from this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
PORTIONS OF UNITS COMMAND FUNCTIONALITY
/*
 * Copyright 2005 Sun Microsystems, Inc.  All rights reserved.
 * Use is subject to license terms.
 */

/*	Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T	*/
/*	  All Rights Reserved	*/

/*
 * Copyright (c) 1980 Regents of the University of California.
 * All rights reserved.  The Berkeley Software License Agreement
 * specifies the terms and conditions for redistribution.
 */

#include <stdio.h>
#include <locale.h>
#include <signal.h>

#define	NDIM	10
#define	NTAB	1009
char	*dfile	= "/usr/share/lib/unittab";
char	*unames[NDIM];
struct unit
{
	double	factor;
	char	dim[NDIM];
};

struct table
{
	double	factor;
	char	dim[NDIM];
	char	*name;
} table[NTAB];
char	names[NTAB*10];
struct prefix
{
	double	factor;
	char	*pname;
} prefix[] =
{
	1e-21,	"zepto",
	1e-24,	"yocto",
	1e-18,	"atto",
	1e-15,	"femto",
	1e-12,	"pico",
	1e-9,	"nano",
	1e-6,	"micro",
	1e-3,	"milli",
	1e-2,	"centi",
	1e-1,	"deci",
	1e1,	"deka",
	1e1,	"deca",
	1e2,	"hecta",
	1e2,	"hecto",
	1e3,	"kilo",
	1e6,	"mega",
	1e6,	"meg",
	1e9,	"giga",
	1e12,	"tera",
	1e15,	"peta",
	1e18,	"exa",
	1e21,	"zetta",
	1e24,	"yotta",
	1<<10,	"kibi",
	1L<<20,	"mebi",
	1L<<30,	"gibi",
	1LL<<40,"tebi",
	0.0,	0
};
FILE	*inp;
int	fperrc;
int	peekc;
int	dumpflg;

void fperr(int sig);
double getflt(void);
struct table *hash(char *name);
int get(void);
void init(void);
int equal(char *s1, char *s2);
int lookup(char *name, struct unit *up, int den, int c);
int convr(struct unit *up);
int pu(int u, int i, int f);
void units(struct unit *up);

int
main(int argc, char *argv[])
{
	int i;
	char *file;
	struct unit u1, u2;
	double f;

	(void) setlocale(LC_ALL, "");
#if !defined(TEXT_DOMAIN)
#define TEXT_DOMAIN "SYS_TEST"
#endif
        (void) textdomain(TEXT_DOMAIN);

	if(argc>1 && *argv[1]=='-') {
		argc--;
		argv++;
		dumpflg++;
	}
	file = dfile;
	if(argc > 1)
		file = argv[1];
	if ((inp = fopen(file, "r")) == NULL) {
		printf(gettext("no table\n"));
		exit(1);
	}
	signal(8, fperr);
	init();

loop:
	fperrc = 0;
	printf(gettext("you have: "));
	if(convr(&u1))
		goto loop;
	if(fperrc)
		goto fp;
loop1:
	printf(gettext("you want: "));
	if(convr(&u2))
		goto loop1;
	for(i=0; i<NDIM; i++)
		if(u1.dim[i] != u2.dim[i])
			goto conform;
	f = u1.factor/u2.factor;
	if(fperrc || f == 0.0)
		goto fp;
	printf("\t* %e\n", f);
	printf("\t/ %e\n", 1./f);
	goto loop;

conform:
	if(fperrc)
		goto fp;
	printf(gettext("conformability\n"));
	units(&u1);
	units(&u2);
	goto loop;

fp:
	printf(gettext("underflow or overflow\n"));
	goto loop;
}

void
units(struct unit *up)
{
	struct unit *p;
	int f, i;

	p = up;
	printf("\t%e ", p->factor);
	f = 0;
	for(i=0; i<NDIM; i++)
		f |= pu(p->dim[i], i, f);
	if(f&1) {
		putchar('/');
		f = 0;
		for(i=0; i<NDIM; i++)
			f |= pu(-p->dim[i], i, f);
	}
	putchar('\n');
}

int
pu(int u, int i, int f)
{

	if(u > 0) {
		if(f&2)
			putchar('-');
		if(unames[i])
			printf("%s", unames[i]);
		else
			printf(gettext("*%c*"), i+'a');
		if(u > 1)
			putchar(u+'0');
		return(2);
	}
	if(u < 0)
		return(1);
	return(0);
}

int
convr(struct unit *up)
{
	struct unit *p;
	int c;
	char *cp;
	char name[20];
	int den, err;

	p = up;
	for(c=0; c<NDIM; c++)
		p->dim[c] = 0;
	p->factor = getflt();
	if(p->factor == 0.)
		p->factor = 1.0;
	err = 0;
	den = 0;
	cp = name;

loop:
	switch(c=get()) {

	case '1':
	case '2':
	case '3':
	case '4':
	case '5':
	case '6':
	case '7':
	case '8':
	case '9':
	case '-':
	case '/':
	case ' ':
	case '\t':
	case '\n':
		if(cp != name) {
			*cp++ = 0;
			cp = name;
			err |= lookup(cp, p, den, c);
		}
		if(c == '/')
			den++;
		if(c == '\n')
			return(err);
		goto loop;
	}
	*cp++ = c;
	goto loop;
}

int
lookup(char *name, struct unit *up, int den, int c)
{
	struct unit *p;
	struct table *q;
	int i;
	char *cp1, *cp2;
	double e;

	p = up;
	e = 1.0;

loop:
	q = hash(name);
	if(q->name) {
		l1:
		if(den) {
			p->factor /= q->factor*e;
			for(i=0; i<NDIM; i++)
				p->dim[i] -= q->dim[i];
		} else {
			p->factor *= q->factor*e;
			for(i=0; i<NDIM; i++)
				p->dim[i] += q->dim[i];
		}
		if(c >= '2' && c <= '9') {
			c--;
			goto l1;
		}
		return(0);
	}
	for(i=0; cp1 = prefix[i].pname; i++) {
		cp2 = name;
		while(*cp1 == *cp2++)
			if(*cp1++ == 0) {
				cp1--;
				break;
			}
		if(*cp1 == 0) {
			e *= prefix[i].factor;
			name = cp2-1;
			goto loop;
		}
	}
	for(cp1 = name; *cp1; cp1++);
	if(cp1 > name+1 && *--cp1 == 's') {
		*cp1 = 0;
		goto loop;
	}
	printf(gettext("cannot recognize %s\n"), name);
	return(1);
}

int
equal(char *s1, char *s2)
{
	char *c1, *c2;

	c1 = s1;
	c2 = s2;
	while(*c1++ == *c2)
		if(*c2++ == 0)
			return(1);
	return(0);
}

void
init(void)
{
	char *cp;
	struct table *tp, *lp;
	int c, i, f, t;
	char *np;

	cp = names;
	for(i=0; i<NDIM; i++) {
		np = cp;
		*cp++ = '*';
		*cp++ = i+'a';
		*cp++ = '*';
		*cp++ = 0;
		lp = hash(np);
		lp->name = np;
		lp->factor = 1.0;
		lp->dim[i] = 1;
	}
	lp = hash("");
	lp->name = cp-1;
	lp->factor = 1.0;

l0:
	c = get();
	if(c == 0) {
		if(dumpflg) {
		printf(gettext("%d units; %d bytes\n\n"), i, cp-names);
		for(tp = &table[0]; tp < &table[NTAB]; tp++) {
			if(tp->name == 0)
				continue;
			printf("%s", tp->name);
			units((struct unit *)tp);
		} }
		fclose(inp);
		inp = stdin;
		return;
	}
	if(c == '/') {
		while(c != '\n' && c != 0)
			c = get();
		goto l0;
	}
	if(c == '\n')
		goto l0;
	np = cp;
	while(c != ' ' && c != '\t') {
		*cp++ = c;
		c = get();
		if (c==0)
			goto l0;
		if(c == '\n') {
			*cp++ = 0;
			tp = hash(np);
			if(tp->name)
				goto redef;
			tp->name = np;
			tp->factor = lp->factor;
			for(c=0; c<NDIM; c++)
				tp->dim[c] = lp->dim[c];
			i++;
			goto l0;
		}
	}
	*cp++ = 0;
	lp = hash(np);
	if(lp->name)
		goto redef;
	convr((struct unit *)lp);
	lp->name = np;
	f = 0;
	i++;
	if(lp->factor != 1.0)
		goto l0;
	for(c=0; c<NDIM; c++) {
		t = lp->dim[c];
		if(t>1 || (f>0 && t!=0))
			goto l0;
		if(f==0 && t==1) {
			if(unames[c])
				goto l0;
			f = c+1;
		}
	}
	if(f>0)
		unames[f-1] = np;
	goto l0;

redef:
	printf(gettext("redefinition %s\n"), np);
	goto l0;
}

double
getflt(void)
{
	int c, i, dp;
	double d, e;
	int f;

	d = 0.;
	dp = 0;
	do
		c = get();
	while(c == ' ' || c == '\t');

l1:
	if(c >= '0' && c <= '9') {
		d = d*10. + c-'0';
		if(dp)
			dp++;
		c = get();
		goto l1;
	}
	if(c == '.') {
		dp++;
		c = get();
		goto l1;
	}
	if(dp)
		dp--;
	if(c == '+' || c == '-') {
		f = 0;
		if(c == '-')
			f++;
		i = 0;
		c = get();
		while(c >= '0' && c <= '9') {
			i = i*10 + c-'0';
			c = get();
		}
		if(f)
			i = -i;
		dp -= i;
	}
	e = 1.;
	i = dp;
	if(i < 0)
		i = -i;
	while(i--)
		e *= 10.;
	if(dp < 0)
		d *= e; else
		d /= e;
	if(c == '|')
		return(d/getflt());
	peekc = c;
	return(d);
}

int
get(void)
{
	int c;

	if(c=peekc) {
		peekc = 0;
		return(c);
	}
	c = getc(inp);
	if (c == EOF) {
		if (inp == stdin) {
			printf("\n");
			exit(0);
		}
		return(0);
	}
	return(c);
}

struct table *
hash(char *name)
{
	struct table *tp;
	char *np;
	unsigned int h;

	h = 0;
	np = name;
	while(*np)
		h = h*57 + *np++ - '0';
	if( ((int)h)<0) h= -(int)h;
	h %= NTAB;
	tp = &table[h];
l0:
	if(tp->name == 0)
		return(tp);
	if(equal(name, tp->name))
		return(tp);
	tp++;
	if(tp >= &table[NTAB])
		tp = table;
	goto l0;
}

void
fperr(int sig)
{

	signal(8, fperr);
	fperrc++;
}
/
/ Copyright 2002 Sun Microsystems, Inc.  All rights reserved.
/ Use is subject to license terms.
/
/ Copyright (c) 1980 Regents of the University of California.
/ All rights reserved.  The Berkeley Software License Agreement
/ specifies the terms and conditions for redistribution.
/

/ ident	"%Z%%M%	%I%	%E% SMI"
/ dimensions
m			*a*
kg			*b*
sec			*c*
coul			*d*
candela			*e*
dollar			*f*
radian			*g*
bit			*h*
erlang			*i*
degC			*j*

/ Authoritative places to get updated values:
/    http://physics.nist.gov/cuu/
/    http://www.npl.co.uk/npl/reference/index.html
/ Less authoritative but very useful for non-SI units is
/    http://www.ex.ac.uk/cimt/dictunit/dictunit.htm

/ constants

fuzz			1
pi			3.14159265358979323846 fuzz
/ speed of light in a vacuum
c			2.99792458+8 m/sec
/ standard acceleration due to gravity
g			9.80665 m/sec2
/ Astronomical Unit
au			1.4959787069+11 m fuzz
/ Avagadro's number
mole			6.022137+23 fuzz
/ charge on an electron
e			1.6021773-19 coul fuzz
/ covert mass to energy (e.g., you have: kilogram energy  you want: megaton tnt)
energy			c2
/ convert mass to weight (e.g., use "lb-force" to get a pound of force)
force			g
/ density of mercury expressed as weight/volume)
mercury			1.33322+5 kg/m2-sec2
hg			mercury

/ dimensionless

degree			1|180 pi-radian
circle			2 pi-radian
turn			2 pi-radian
grade			.9 degree
arcdeg			1 degree
arcmin			1|60 arcdeg
ccs			1|36 erlang
arcsec			1|60 arcmin

steradian		radian2
sphere			4 pi-steradian
sr			steradian

/ Time

second			sec
s			sec
minute			60 sec
min			minute
hour			60 min
hr			hour
day			24 hr
da			day
week			7 day
/ Mean tropical year in the year 2000.  This decreases by .00000615 per century.
year			365.2421896698 day fuzz
yr			year
month			1|12 year
ms			millisec
us			microsec

/ Mass

gram			millikg
gm			gram
mg			milligram
metricton		kilokg

/ Avoirdupois

lb			.45359237 kg
lbf			lb g
ounce			1|16 lb
oz			ounce
dram			1|16 oz
dr			dram
grain			1|7000 lb
gr			grain
shortton		2000 lb
ton			shortton
longton			2240 lb

/ Apothecary

scruple			20 grain
apdram			60 grain
apounce			480 grain
appound			5760 grain

/ Length

meter			m
metre			m
cm			centimeter
mm			millimeter
km			kilometer
nm			nanometer
micron			micrometer
angstrom		decinanometer

inch			2.54 cm
in			inch
foot			12 in
feet			foot
ft			foot
yard			3 ft
yd			yard
rod			5.5 yd
rd			rod
mile			5280 ft
mi			mile

british			1200|3937 m/ft
nmile			1852m

acre			4840 yd2

cc			cm3
liter			kilocc
litre			liter
ml			milliliter

/ US Liquid

gallon			231 in3
imperial		1.20095
gal			gallon
quart			1|4 gal
qt			quart
pint			1|2 qt
pt			pint

floz			1|16 pt
fldr			1|8 floz

/ US Dry

dry			268.8025 in3/gallon
peck			8 dry-quart
pk			peck
bushel			4 peck
bu			bushel

/ British

brgallon		4.54609 litre
brquart			1|4 brgallon
brpint			1|2 brquart
brgill			1|4 brpint
brfloz			1|20 brpint
brpeck			9.09218 litre
brbushel		4 brpeck

/ Energy Work

newton			kg-m/sec2
nt			newton
joule			nt-m
/ There are 5 different small calories.  The one used here is the "IT
/ calorie".  The "USA calorie" or "thermochemical calorie" is 4.184 joule
/ (exact).  The "calorie at 15 deg C" is 4.1855 joule fuzz.  The "calorie
/ at 20 deg C" is 4.1819 joule fuzz.  The "mean calorie" is 4.19002 joule
/ fuzz.  The large Calorie is a thousand of (one of) these calories.
cal			4.1868 joule

/ Electrical

coulomb			coul
ampere			coul/sec
amp			ampere
watt			joule/sec
volt			watt/amp
ohm			volt/amp
mho			/ohm
farad			coul/volt
henry			sec2/farad
weber			volt-sec

/ Light & Radiation

cd			candela
lumen			cd sr
lux			cd sr/m2
/ actual radiation dose
gray			joule/kg
/ effective radiation dose
sievert			joule/kg

/ Temperature

kelvin			degC
rankine			5|9 kelvin
degF			rankine
/ note that degF and degC are suitable for converting temperature intervals,
/ but not actual temperatures on the Fahrenheit and Celsius scales.

/ Money
/ epoch May 22, 1998
/ floating rates from Los Angeles Times
/ fixed rates from http://dylee.keel.econ.ship.edu/intntl/intfin/currencies.htm
/ Currencies pegged by the country to another currency are shown exactly
/ (of course, they are still subject to change).  Others are shown as "fuzz".

$			dollar
argentinapeso		1.0000 $
australiadollar		0.6297 $   fuzz
brazilreal		0.8705 $   fuzz
britainpound		1.6327 $   fuzz
canadadollar		0.9899 $   fuzz
chilepeso		0.002204 $ fuzz
chinayuanrenminbi	0.1208 $   fuzz
colombiapeso		0.000719 $ fuzz
czechkoruna		0.0308 $   fuzz
denmarkkrone		1.491 $    fuzz
dominicanrepublicpeso	0.0664 $   fuzz
equadorsucre		0.000196 $ fuzz
egyptpound		0.2927 $   fuzz
hongkongdollar		1|7.73 $
hungaryforint		1|211.02 $ fuzz
indiarupee		0.0247 $   fuzz
indonesiarupiah		1|11050 $  fuzz
iranrial		0.000333 $ fuzz
iraqdinar		1|.3109 $
israelnewshekel		0.2743 $   fuzz
israelshekel		.001 israelnewshekel
israelpound		.1 israelshekel
japanyen		0.007419 $ fuzz
jordandinar		1.4134 $   fuzz
lebanonpound		1|1519.5 $ fuzz
malaysiaringgit		0.2654 $   fuzz
malaysiadollar		malaysiaringgit
mexicopeso		0.115781 $ fuzz
newzealanddollar	0.5338 $   fuzz
norwaykrone		0.1342 $   fuzz
pakistanrupee		0.0229 $   fuzz
perusol			0.3532 $   fuzz
perunewsol		perusol
philippinespeso		0.0258 $   fuzz
polandnewzloty		0.2882 $   fuzz
russiaruble		0.1624 $   fuzz
saudiarabiariyal	0.2667 $   fuzz
singaporedollar		0.6109 $   fuzz
slovakiakoruna		0.0293 $   fuzz
southafricarand		0.1968 $   fuzz
southkoreawon		0.00072 $  fuzz
swedenkrona		0.1302 $   fuzz
switzerlandfranc	0.6841 $   fuzz
taiwannewdollar		0.0298 $   fuzz
thailandbaht		0.02541 $  fuzz
turkeylira		1|253780 $ fuzz
uaedirham		0.2724 $   fuzz
uruguaypeso		0.0966 $   fuzz
venezuelabolivar	1|535.5 $  fuzz

/ The euro and currencies tied to it.
/ See http://www.x-rates.com/faq_euro.html
/ or http://europa.eu.int/euro/html/entry.html
/ euro to $ as of 16 Jan 2002.
euro			0.8834 $ fuzz
austriaschilling	1|13.7603 euro
belgiumfranc		1|40.3399 euro
finlandmarkka		1|5.94573 euro
francefranc		1|6.55957 euro
germanymark		1|1.95583 euro
greecedrachma		1|340.750 euro
irelandpound		1|.787564 euro
italylira		1|1936.27 euro
luxembourgfranc		1|40.3399 euro
netherlandsguilder	1|2.20371 euro
portugalescudo		1|200.482 euro
spainpeseta		1|166.386 euro

mark			germanymark
bolivar			venezuelabolivar
peseta			spainpeseta
rand			southafricarand
escudo			portugalescudo
sol			perusol
guilder			netherlandsguilder
peso			mexicopeso
yen			japanyen
lira			italylira
dinar			iraqdinar
rial			iranrial
rupee			indiarupee
drachma			greecedrachma
franc			francefranc
markka			finlandmarkka
sucre			equadorsucre
pound			britainpound
poundsterling		britainpound
/ cruzeiro		brazilcruzeiro

/ PDP-11

baud			bit/sec
byte			8 bit
word			2 byte
block			512 byte
K			1024 word
tc			578 block
rktrack			12 block
rkcylinder		2 rktrack
rk			203 rkcylinder
rptrack			10 block
rpcylinder		20 rptracks
rp			406 rpcylinder
rftrack			8 block
rfshoe			8 rftrack
rfdisk			16 rfshoe
rf			2 rfdisk

/ Trivia

%			1|100
admiraltyknot		6080 ft/hr
apostilb		cd/pi-m2
are			1+2 m2
arpentcan		27.52 mi
arpentlin		191.835 ft
astronomicalunit	au
atmosphere		1.01325+5 nt/m2
atm			atmosphere
atomicmassunit		gm/mole
amu			atomicmassunit
bag			94 lb
bakersdozen		13
bar			1+5 nt/m2
barie			1-1 nt/m2
barleycorn		1|3 in
barn			1-28 m2
barrel			42 gal
barye			1-1 nt/m2
/ radiation activity
becquerel		/sec
bev			1+9 e-volt
biot			10 amp
blondel			cd/pi-m2
boardfoot		144 in3
bolt			40 yd
boltzmann		1.38066-23 joule/degC fuzz
k			boltzmann
bottommeasure		1|40 in
britishthermalunit	cal lb-degF/gm-degC
btu			britishthermalunit
refrigeration		12000 btu/ton-hour
buck			dollar
cable			720 ft
caliber			1-2 in
calorie			cal
carat			205 mg
cent			centidollar
cental			100 lb
centesimalminute	1-2 grade
centesimalsecond	1-4 grade
century			100 year
cfs			ft3/sec
chain			66 ft
circularinch		1|4 pi-in2
circularmil		1-6|4 pi-in2
clusec			1-8 mm-hg m3/s
coomb			4 bu
cord			128 ft3
cordfoot		cord
crith			9.06-2 gm
cubit			18 in
cup			1|2 pt
curie			3.7+10 /sec
dalton			amu
decade			10 yr
dioptre			/m
displacementton		35 ft3
doppelzentner		100 kg
dozen			12
drop			.03 cm3
dyne			cm-gm/sec2
electronvolt		e-volt
ell			45 in
engineerschain		100 ft
engineerslink		100|100 ft
equivalentfootcandle	lumen/pi-ft2
equivalentlux	lumen/pi-m2
equivalentphot		cd/pi-cm2
erg			cm2-gm/sec2
ev			e-volt
faraday			9.652+4 coul
fathom			6 ft
fermi			1-15 m
fifth			4|5 qt
fin			5 dollar
finger			7|8 in
firkin			9 gal
footcandle		lumen/ft2
footlambert		cd/pi-ft2
fortnight		14 da
franklin		3.33564-10 coul
frigorie		kilocal
furlong			220 yd
/ Universal Gravitational Constant
G			6.673-11 m3/kg-sec2 fuzz
galileo			1-2 m/sec2
gamma			1-9 weber/m2
gauss			1-4 weber/m2
geodeticfoot		british-ft
geographicalmile	1852 m
gilbert			7.95775-1 amp
gill			1|4 pt
gross			144
gunterschain		22 yd
hand			4 in
/ Planck's constant
hbar			1.054573-34 joule-sec fuzz
h			2 pi hbar
hectare			1+4 m2
hefnercandle		.92 cd
hertz			/sec
hogshead		2 barrel
hd			hogshead
homestead		1|4 mi2
horsepower		550 ft-lb-g/sec
hp			horsepower
hyl			gm force sec2/m
hz			/sec
imaginarycubicfoot	1.4 ft3
/ radio intensity
jansky			1-26 watt/m2-hz
jeroboam		4|5 gal
karat			1|24
kcal			kilocal
kcalorie		kilocal
kev			1+3 e-volt
key			kg
khz			1+3 /sec
kilderkin		18 gal
knot			nmile/hr
lambert			cd/pi-cm2
langley			cal/cm2
last			80 bu
league			3 mi
lightyear		c-yr
line			1|12 in
link			66|100 ft
longhundredweight	112 lb
longquarter		28 lb
lusec			1-6 mm-hg m3/s
mach			331.46 m/sec
magnum			2 qt
marineleague		3 nmile
maxwell			1-8 weber
metriccarat		200 mg
mev			1+6 e-volt
mgd			megagal/day
mh			millihenry
mhz			1+6 /sec
mil			1-3 in
millenium		1000 year
minersinch		1.5 ft3/min
minim			1|60 fldr
mo			month
mpg			mile/gal
mph			mile/hr
nail			1|16 yd
nauticalmile		nmile
nit			cd/m2
noggin			1|8 qt
nox			1-3 lux
ns			nanosec
oersted			2.5+2 pi-amp/m
oe			oersted
pace			36 in
palm			3 in
parasang		3.5 mi
parsec			au-radian/arcsec
pascal			nt/m2
pc			parsec
pennyweight		1|20 oz
percent			%
perch			rd
pf			picofarad
phot			lumen/cm2
pica			1|6 in
pieze			1+3 nt/m2
pipe			4 barrel
point			1|72 in
poise			gm/cm-sec
pole			rd
poundal			ft-lb/sec2
pdl			poundal
proof			1|200
psi			lb-g/in2
quarter			9 in
quartersection		1|4 mi2
quintal			100 kg
quire			25
/ actual radiation dose
rad			1-2 gray
ream			500
registerton		100 ft3
rehoboam		156 floz
/ effective radiation dose
rem			1-2 sievert
rhe			10 m2/nt-sec
/ ionization power of radiation
rontgen			2.58-4 coul/kg
roentgen		rontgen
rood			1.21+3 yd2
rope			20 ft
rutherford		1+6 /sec
/ This is the rydberg energy (ionization energy of hydrogen assuming infinite
/ mass nucleus).  To get the "rydberg constant", use rydberg/h-c
rydberg			13.605698 ev fuzz
sabin			1 ft2
sack			3 bu
seam			8 bu
section			mi2
shippington		40 ft3
shorthundredweight	100 lb
shortquarter		25 lb
siemens			/ohm
sigma			microsec
skein			120 yd
skot			1-3 apostilb
slug			lb-g-sec2/ft
span			9 in
spat			4 pi sr
spindle			14400 yd
square			100 ft2
stere			m3
sthene			1+3 nt
stilb			cd/cm2
stoke			1-4 m2/sec
stone			14 lb
strike			2 bu
surveyfoot		british-ft
surveyorschain		66 ft
surveyorslink		66|100 ft
tablespoon		4 fldr
teaspoon		4|3 fldr
tesla			weber/m2
therm			1+5 btu
thermie			1+6 cal
timberfoot		ft3
tnt			4.6+6 m2/sec2
tonne			1+6 gm
torr			mm hg
township		36 mi2
tun			8 barrel
water			.22491|2.54 kg/m2-sec2
wey			40 bu
weymass			252 lb
Xunit			1.00202-13m