28 static double conv_length[7][7] = {
29 { 1.0, 2.54e-3, 2.54e-2, 2.54e-5, 25.4, 1.e-3, 1./12000},
30 {1./2.54e-3, 1.0, 10.0, 1.e-2, 1.e4, 1./2.54, 1./30.48},
31 {1./2.54e-2, 1./10., 1.0, 1.e-3, 1.e3, 1./25.4, 1./304.8},
32 {1./2.54e-5, 1.e2, 1.e3, 1.0, 1.e6, 1./2.54e-2, 1./0.3048},
33 {1./25.4, 1.e-4, 1.e-3, 1.e-6, 1.0, 1./2.54e4, 1./3.048e5},
34 {1.e3, 2.54, 25.4, 2.54e-2, 2.54e4, 1.0, 1./12.},
35 {1.2e4, 30.48, 304.8, 0.3048, 3.048e5, 12.0, 1.0}
39 static double conv_freq[4][4] = {
40 { 1.0, 1.e9, 1.e6, 1.e3},
41 { 1.e-9, 1.0, 1.e-3, 1.e-6},
42 { 1.e-6, 1.e3, 1.0, 1.e-3},
43 { 1.e-3, 1.e6, 1.e3, 1.0}
47 static double conv_res[2][2] = {
53 static double conv_ang[2][2] = {
85 value *= conv_length[srcunit][dstunit];
87 value *= conv_res[srcunit][dstunit];
89 value *= conv_ang[srcunit][dstunit];
91 value *= conv_freq[srcunit][dstunit];
99 sprintf (text,
"%g %s", value, unit);
124 return value * conv_length[srcunit][dstunit];
126 return value * conv_res[srcunit][dstunit];
128 return value * conv_ang[srcunit][dstunit];
130 return value * conv_freq[srcunit][dstunit];
140 value *= conv_length[srcunit][dstunit];
142 value *= conv_res[srcunit][dstunit];
144 value *= conv_ang[srcunit][dstunit];
146 value *= conv_freq[srcunit][dstunit];
159 else if (!strcmp (text,
"cm"))
return LENGTH_CM;
160 else if (!strcmp (text,
"mm"))
return LENGTH_MM;
161 else if (!strcmp (text,
"m"))
return LENGTH_M;
162 else if (!strcmp (text,
"um"))
return LENGTH_UM;
163 else if (!strcmp (text,
"in"))
return LENGTH_IN;
164 else if (!strcmp (text,
"ft"))
return LENGTH_FT;
166 else if (!strcmp (text,
"GHz"))
return FREQ_GHZ;
167 else if (!strcmp (text,
"Hz"))
return FREQ_HZ;
168 else if (!strcmp (text,
"kHz"))
return FREQ_KHZ;
169 else if (!strcmp (text,
"MHz"))
return FREQ_MHZ;
171 else if (!strcmp (text,
"Ohm"))
return RES_OHM;
172 else if (!strcmp (text,
"kOhm"))
return RES_KOHM;
174 else if (!strcmp (text,
"Deg"))
return ANG_DEG;
175 else if (!strcmp (text,
"Rad"))
return ANG_RAD;