@danielsimonjr/mathts-core 0.16.0 → 0.18.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{chunk-MBKU4LYX.js → chunk-UEBMU6EV.js} +1104 -1586
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +145 -132
- package/dist/internal.js +1 -1
- package/dist/types/unit/Unit.d.ts.map +1 -1
- package/dist/types/unit/exact-scale.d.ts +119 -0
- package/dist/types/unit/exact-scale.d.ts.map +1 -0
- package/dist/types/unit/index.d.ts +4 -0
- package/dist/types/unit/index.d.ts.map +1 -1
- package/dist/types/unit/unit-table.d.ts +100 -0
- package/dist/types/unit/unit-table.d.ts.map +1 -0
- package/dist/types/unit/unit-types.d.ts +18 -3
- package/dist/types/unit/unit-types.d.ts.map +1 -1
- package/dist/types/unit-definitions.d.ts +4 -0
- package/dist/types/unit-definitions.d.ts.map +1 -1
- package/dist/types/unit-prefixes.d.ts +4 -2
- package/dist/types/unit-prefixes.d.ts.map +1 -1
- package/dist/types/unit.d.ts +2 -0
- package/dist/types/unit.d.ts.map +1 -1
- package/package.json +1 -1
|
@@ -2148,7 +2148,867 @@ var DimensionMismatchError = class extends Error {
|
|
|
2148
2148
|
}
|
|
2149
2149
|
};
|
|
2150
2150
|
|
|
2151
|
+
// src/types/unit/exact-scale.ts
|
|
2152
|
+
var NAMED_IRRATIONALS = Object.freeze({
|
|
2153
|
+
pi: "3.141592653589793238462643383279502884197169399375105820974944592307816406286208998628034825342117067982148086513282306647",
|
|
2154
|
+
ln2: "0.693147180559945309417232121458176568075500134360255254120680009493393621969694715605863326996418687542001481020570685733"
|
|
2155
|
+
});
|
|
2156
|
+
function isIrrationalName(name2) {
|
|
2157
|
+
return Object.prototype.hasOwnProperty.call(NAMED_IRRATIONALS, name2);
|
|
2158
|
+
}
|
|
2159
|
+
function irrationalPower(s, name2) {
|
|
2160
|
+
return s.irrationals[name2] ?? 0;
|
|
2161
|
+
}
|
|
2162
|
+
function isRationalScale(s) {
|
|
2163
|
+
return Object.keys(s.irrationals).length === 0;
|
|
2164
|
+
}
|
|
2165
|
+
var NO_IRRATIONALS = Object.freeze({});
|
|
2166
|
+
function combinePowers(a, b, sign2) {
|
|
2167
|
+
if (Object.keys(b).length === 0) return a;
|
|
2168
|
+
const out = {};
|
|
2169
|
+
let any = false;
|
|
2170
|
+
for (const name2 of Object.keys(NAMED_IRRATIONALS)) {
|
|
2171
|
+
const k = (a[name2] ?? 0) + sign2 * (b[name2] ?? 0);
|
|
2172
|
+
if (k !== 0) {
|
|
2173
|
+
out[name2] = k;
|
|
2174
|
+
any = true;
|
|
2175
|
+
}
|
|
2176
|
+
}
|
|
2177
|
+
return any ? Object.freeze(out) : NO_IRRATIONALS;
|
|
2178
|
+
}
|
|
2179
|
+
function scalePowers(a, n) {
|
|
2180
|
+
if (n === 0) return NO_IRRATIONALS;
|
|
2181
|
+
if (n === 1 || Object.keys(a).length === 0) return a;
|
|
2182
|
+
const out = {};
|
|
2183
|
+
for (const name2 of Object.keys(a)) out[name2] = a[name2] * n;
|
|
2184
|
+
return Object.freeze(out);
|
|
2185
|
+
}
|
|
2186
|
+
function powersEqual(a, b) {
|
|
2187
|
+
for (const name2 of Object.keys(NAMED_IRRATIONALS)) {
|
|
2188
|
+
if ((a[name2] ?? 0) !== (b[name2] ?? 0)) return false;
|
|
2189
|
+
}
|
|
2190
|
+
return true;
|
|
2191
|
+
}
|
|
2192
|
+
var SAFE_GCD = 1n << 53n;
|
|
2193
|
+
function gcd(a, b) {
|
|
2194
|
+
let x = a < 0n ? -a : a;
|
|
2195
|
+
let y = b < 0n ? -b : b;
|
|
2196
|
+
if (x <= SAFE_GCD && y <= SAFE_GCD) {
|
|
2197
|
+
let p = Number(x);
|
|
2198
|
+
let q = Number(y);
|
|
2199
|
+
while (q !== 0) [p, q] = [q, p % q];
|
|
2200
|
+
return BigInt(p);
|
|
2201
|
+
}
|
|
2202
|
+
while (y !== 0n) [x, y] = [y, x % y];
|
|
2203
|
+
return x;
|
|
2204
|
+
}
|
|
2205
|
+
function isOne(s) {
|
|
2206
|
+
return s.num === 1n && s.den === 1n && isRationalScale(s);
|
|
2207
|
+
}
|
|
2208
|
+
function make(num, den, irrationals) {
|
|
2209
|
+
if (den === 0n) throw new RangeError("exact scale: zero denominator");
|
|
2210
|
+
if (den < 0n) {
|
|
2211
|
+
num = -num;
|
|
2212
|
+
den = -den;
|
|
2213
|
+
}
|
|
2214
|
+
const g = gcd(num, den);
|
|
2215
|
+
return g > 1n ? { num: num / g, den: den / g, irrationals } : { num, den, irrationals };
|
|
2216
|
+
}
|
|
2217
|
+
var UNIT_EXACT_SCALE = Object.freeze({
|
|
2218
|
+
num: 1n,
|
|
2219
|
+
den: 1n,
|
|
2220
|
+
irrationals: NO_IRRATIONALS
|
|
2221
|
+
});
|
|
2222
|
+
function namedIrrationalScale(name2) {
|
|
2223
|
+
return Object.freeze({ num: 1n, den: 1n, irrationals: Object.freeze({ [name2]: 1 }) });
|
|
2224
|
+
}
|
|
2225
|
+
var PI_EXACT_SCALE = namedIrrationalScale("pi");
|
|
2226
|
+
var LN2_EXACT_SCALE = namedIrrationalScale("ln2");
|
|
2227
|
+
var DECIMAL = /^([+-]?)(\d*)(?:\.(\d*))?(?:[eE]([+-]?\d+))?$/;
|
|
2228
|
+
function decimalExactScale(text) {
|
|
2229
|
+
const m = DECIMAL.exec(text.trim());
|
|
2230
|
+
if (m === null) return null;
|
|
2231
|
+
const whole = m[2] ?? "";
|
|
2232
|
+
const fraction = m[3] ?? "";
|
|
2233
|
+
if (whole === "" && fraction === "") return null;
|
|
2234
|
+
const exponent = Number(m[4] ?? "0") - fraction.length;
|
|
2235
|
+
if (!Number.isSafeInteger(exponent) || Math.abs(exponent) > 1e4) return null;
|
|
2236
|
+
let num = BigInt(whole + fraction);
|
|
2237
|
+
if (m[1] === "-") num = -num;
|
|
2238
|
+
return exponent >= 0 ? make(num * 10n ** BigInt(exponent), 1n, NO_IRRATIONALS) : make(num, 10n ** BigInt(-exponent), NO_IRRATIONALS);
|
|
2239
|
+
}
|
|
2240
|
+
function exactScaleOf(x) {
|
|
2241
|
+
if (!Number.isFinite(x)) throw new RangeError(`exact scale: ${x} is not finite`);
|
|
2242
|
+
if (Number.isSafeInteger(x)) return make(BigInt(x), 1n, NO_IRRATIONALS);
|
|
2243
|
+
return decimalExactScale(String(x));
|
|
2244
|
+
}
|
|
2245
|
+
function binaryExactScale(x) {
|
|
2246
|
+
if (!Number.isFinite(x)) throw new RangeError(`exact scale: ${x} is not finite`);
|
|
2247
|
+
if (x === 0) return make(0n, 1n, NO_IRRATIONALS);
|
|
2248
|
+
const view = new DataView(new ArrayBuffer(8));
|
|
2249
|
+
view.setFloat64(0, x);
|
|
2250
|
+
const bits = view.getBigUint64(0);
|
|
2251
|
+
const negative = bits >> 63n === 1n;
|
|
2252
|
+
const biased = Number(bits >> 52n & 0x7ffn);
|
|
2253
|
+
const fraction = bits & (1n << 52n) - 1n;
|
|
2254
|
+
const mantissa = biased === 0 ? fraction : fraction | 1n << 52n;
|
|
2255
|
+
const exponent = (biased === 0 ? 1 : biased) - 1075;
|
|
2256
|
+
const num = negative ? -mantissa : mantissa;
|
|
2257
|
+
return exponent >= 0 ? make(num << BigInt(exponent), 1n, NO_IRRATIONALS) : make(num, 1n << BigInt(-exponent), NO_IRRATIONALS);
|
|
2258
|
+
}
|
|
2259
|
+
function ratioExactScale(num, den = 1n) {
|
|
2260
|
+
return make(BigInt(num), BigInt(den), NO_IRRATIONALS);
|
|
2261
|
+
}
|
|
2262
|
+
function multiplyExactScales(...factors) {
|
|
2263
|
+
if (factors.length === 2) {
|
|
2264
|
+
if (isOne(factors[1])) return factors[0];
|
|
2265
|
+
if (isOne(factors[0])) return factors[1];
|
|
2266
|
+
}
|
|
2267
|
+
let num = 1n;
|
|
2268
|
+
let den = 1n;
|
|
2269
|
+
let irrationals = NO_IRRATIONALS;
|
|
2270
|
+
for (const f of factors) {
|
|
2271
|
+
num *= f.num;
|
|
2272
|
+
den *= f.den;
|
|
2273
|
+
irrationals = combinePowers(irrationals, f.irrationals, 1);
|
|
2274
|
+
}
|
|
2275
|
+
return make(num, den, irrationals);
|
|
2276
|
+
}
|
|
2277
|
+
function divideExactScales(a, b) {
|
|
2278
|
+
if (b.num === 0n) throw new RangeError("exact scale: division by zero");
|
|
2279
|
+
if (isOne(b)) return a;
|
|
2280
|
+
return make(a.num * b.den, a.den * b.num, combinePowers(a.irrationals, b.irrationals, -1));
|
|
2281
|
+
}
|
|
2282
|
+
function powerExactScale(a, n) {
|
|
2283
|
+
if (!Number.isInteger(n)) throw new RangeError(`exact scale: power ${n} is not an integer`);
|
|
2284
|
+
const k = BigInt(Math.abs(n));
|
|
2285
|
+
const up = make(a.num ** k, a.den ** k, scalePowers(a.irrationals, Math.abs(n)));
|
|
2286
|
+
return n >= 0 ? up : divideExactScales(UNIT_EXACT_SCALE, up);
|
|
2287
|
+
}
|
|
2288
|
+
function exactScalesEqual(a, b) {
|
|
2289
|
+
return a.num === b.num && a.den === b.den && (a.num === 0n || powersEqual(a.irrationals, b.irrationals));
|
|
2290
|
+
}
|
|
2291
|
+
function addExactScales(a, b) {
|
|
2292
|
+
if (a.num === 0n) return b;
|
|
2293
|
+
if (b.num === 0n) return a;
|
|
2294
|
+
if (!powersEqual(a.irrationals, b.irrationals)) return null;
|
|
2295
|
+
return make(a.num * b.den + b.num * a.den, a.den * b.den, a.irrationals);
|
|
2296
|
+
}
|
|
2297
|
+
var IRRATIONAL_RATIONALS = Object.freeze(
|
|
2298
|
+
Object.fromEntries(
|
|
2299
|
+
Object.keys(NAMED_IRRATIONALS).map((name2) => [
|
|
2300
|
+
name2,
|
|
2301
|
+
decimalExactScale(NAMED_IRRATIONALS[name2])
|
|
2302
|
+
])
|
|
2303
|
+
)
|
|
2304
|
+
);
|
|
2305
|
+
var SAFE_OPERAND = 1n << 53n;
|
|
2306
|
+
function bitLength(x) {
|
|
2307
|
+
if (x === 0n) return 0;
|
|
2308
|
+
const hex = x.toString(16);
|
|
2309
|
+
return (hex.length - 1) * 4 + (32 - Math.clz32(parseInt(hex[0], 16)));
|
|
2310
|
+
}
|
|
2311
|
+
function rationalToNumber(num, den) {
|
|
2312
|
+
if (num === 0n) return 0;
|
|
2313
|
+
const negative = num < 0n;
|
|
2314
|
+
const a = negative ? -num : num;
|
|
2315
|
+
if (a <= SAFE_OPERAND && den <= SAFE_OPERAND) {
|
|
2316
|
+
const q = Number(a) / Number(den);
|
|
2317
|
+
return negative ? -q : q;
|
|
2318
|
+
}
|
|
2319
|
+
const e = bitLength(a) - bitLength(den);
|
|
2320
|
+
if (e > 1025) return negative ? -Infinity : Infinity;
|
|
2321
|
+
if (e < -1080) return negative ? -0 : 0;
|
|
2322
|
+
let shift = 52 - e;
|
|
2323
|
+
const quotient = (k) => k >= 0 ? (a << BigInt(k)) / den : a / (den << BigInt(-k));
|
|
2324
|
+
if (quotient(shift) < 1n << 52n) shift += 1;
|
|
2325
|
+
if (shift > 1074) shift = 1074;
|
|
2326
|
+
const n = shift >= 0 ? a << BigInt(shift) : a;
|
|
2327
|
+
const d = shift >= 0 ? den : den << BigInt(-shift);
|
|
2328
|
+
let m = n / d;
|
|
2329
|
+
const twice = 2n * (n % d);
|
|
2330
|
+
if (twice > d || twice === d && m % 2n === 1n) m += 1n;
|
|
2331
|
+
if (m === 1n << 53n) {
|
|
2332
|
+
m >>= 1n;
|
|
2333
|
+
shift -= 1;
|
|
2334
|
+
}
|
|
2335
|
+
if (52 - shift > 1023) return negative ? -Infinity : Infinity;
|
|
2336
|
+
const value = Number(m) * 2 ** -shift;
|
|
2337
|
+
if (!Number.isFinite(value)) return negative ? -Infinity : Infinity;
|
|
2338
|
+
return negative ? -value : value;
|
|
2339
|
+
}
|
|
2340
|
+
function scaleToRational(s) {
|
|
2341
|
+
let num = s.num;
|
|
2342
|
+
let den = s.den;
|
|
2343
|
+
for (const name2 of Object.keys(s.irrationals)) {
|
|
2344
|
+
const power = s.irrationals[name2];
|
|
2345
|
+
const c = IRRATIONAL_RATIONALS[name2];
|
|
2346
|
+
const k = BigInt(Math.abs(power));
|
|
2347
|
+
if (power > 0) {
|
|
2348
|
+
num *= c.num ** k;
|
|
2349
|
+
den *= c.den ** k;
|
|
2350
|
+
} else {
|
|
2351
|
+
num *= c.den ** k;
|
|
2352
|
+
den *= c.num ** k;
|
|
2353
|
+
}
|
|
2354
|
+
}
|
|
2355
|
+
return { num, den };
|
|
2356
|
+
}
|
|
2357
|
+
var EXACT_SCALE_NUMBER_CACHE_LIMIT = 4096;
|
|
2358
|
+
var numberCache = /* @__PURE__ */ new Map();
|
|
2359
|
+
var roundedByIdentity = /* @__PURE__ */ new WeakMap();
|
|
2360
|
+
function roundExactScale(s) {
|
|
2361
|
+
let value = roundedByIdentity.get(s);
|
|
2362
|
+
if (value === void 0) {
|
|
2363
|
+
const { num, den } = scaleToRational(s);
|
|
2364
|
+
value = rationalToNumber(num, den);
|
|
2365
|
+
roundedByIdentity.set(s, value);
|
|
2366
|
+
}
|
|
2367
|
+
return value;
|
|
2368
|
+
}
|
|
2369
|
+
function powersKey(p) {
|
|
2370
|
+
let key = "";
|
|
2371
|
+
for (const name2 of Object.keys(p)) key += `|${name2}^${p[name2]}`;
|
|
2372
|
+
return key;
|
|
2373
|
+
}
|
|
2374
|
+
function cacheKey(s) {
|
|
2375
|
+
return `${s.num}/${s.den}${powersKey(s.irrationals)}`;
|
|
2376
|
+
}
|
|
2377
|
+
function clearExactScaleNumberCache() {
|
|
2378
|
+
numberCache.clear();
|
|
2379
|
+
}
|
|
2380
|
+
function exactScaleNumberCacheSize() {
|
|
2381
|
+
return numberCache.size;
|
|
2382
|
+
}
|
|
2383
|
+
function exactScaleToNumber(s) {
|
|
2384
|
+
const key = cacheKey(s);
|
|
2385
|
+
const cached = numberCache.get(key);
|
|
2386
|
+
if (cached !== void 0) {
|
|
2387
|
+
numberCache.delete(key);
|
|
2388
|
+
numberCache.set(key, cached);
|
|
2389
|
+
return cached;
|
|
2390
|
+
}
|
|
2391
|
+
const value = roundExactScale(s);
|
|
2392
|
+
numberCache.set(key, value);
|
|
2393
|
+
if (numberCache.size > EXACT_SCALE_NUMBER_CACHE_LIMIT) {
|
|
2394
|
+
numberCache.delete(numberCache.keys().next().value);
|
|
2395
|
+
}
|
|
2396
|
+
return value;
|
|
2397
|
+
}
|
|
2398
|
+
function formatExactScale(s) {
|
|
2399
|
+
const rational = s.den === 1n ? `${s.num}` : `${s.num}/${s.den}`;
|
|
2400
|
+
const parts = [rational];
|
|
2401
|
+
for (const name2 of Object.keys(s.irrationals)) {
|
|
2402
|
+
const k = s.irrationals[name2];
|
|
2403
|
+
parts.push(k === 1 ? name2 : `${name2}^${k}`);
|
|
2404
|
+
}
|
|
2405
|
+
return parts.join("*");
|
|
2406
|
+
}
|
|
2407
|
+
var TOKEN = /\s*(?:([()*/])|\^\s*([+-]?\d+)|([^\s*/^()]+))/y;
|
|
2408
|
+
function tokenize(text) {
|
|
2409
|
+
const tokens = [];
|
|
2410
|
+
TOKEN.lastIndex = 0;
|
|
2411
|
+
let at = 0;
|
|
2412
|
+
while (at < text.length) {
|
|
2413
|
+
if (/^\s*$/.test(text.slice(at))) break;
|
|
2414
|
+
TOKEN.lastIndex = at;
|
|
2415
|
+
const m = TOKEN.exec(text);
|
|
2416
|
+
if (m === null) throw new RangeError(`exact scale: '${text}' is not a product of factors`);
|
|
2417
|
+
if (m[1] !== void 0) tokens.push({ kind: "op", op: m[1] });
|
|
2418
|
+
else if (m[2] !== void 0) tokens.push({ kind: "pow", n: Number(m[2]) });
|
|
2419
|
+
else tokens.push({ kind: "atom", text: m[3] });
|
|
2420
|
+
at = TOKEN.lastIndex;
|
|
2421
|
+
}
|
|
2422
|
+
return tokens;
|
|
2423
|
+
}
|
|
2424
|
+
function readScaleExpression(text, resolve = () => void 0) {
|
|
2425
|
+
const tokens = tokenize(text);
|
|
2426
|
+
let i = 0;
|
|
2427
|
+
const fail = () => {
|
|
2428
|
+
throw new RangeError(`exact scale: '${text}' is not a product of factors`);
|
|
2429
|
+
};
|
|
2430
|
+
const isOp = (op) => {
|
|
2431
|
+
const t = tokens[i];
|
|
2432
|
+
return t !== void 0 && t.kind === "op" && t.op === op;
|
|
2433
|
+
};
|
|
2434
|
+
const factor = () => {
|
|
2435
|
+
const t = tokens[i++];
|
|
2436
|
+
let base;
|
|
2437
|
+
if (t === void 0) return fail();
|
|
2438
|
+
if (t.kind === "op" && t.op === "(") {
|
|
2439
|
+
base = expression();
|
|
2440
|
+
if (!isOp(")")) fail();
|
|
2441
|
+
i++;
|
|
2442
|
+
} else if (t.kind === "atom") {
|
|
2443
|
+
base = decimalExactScale(t.text) ?? (isIrrationalName(t.text) ? namedIrrationalScale(t.text) : resolve(t.text));
|
|
2444
|
+
if (base === void 0) {
|
|
2445
|
+
throw new RangeError(
|
|
2446
|
+
`exact scale: '${text}' names '${t.text}', which is not a known scale`
|
|
2447
|
+
);
|
|
2448
|
+
}
|
|
2449
|
+
} else {
|
|
2450
|
+
return fail();
|
|
2451
|
+
}
|
|
2452
|
+
const p = tokens[i];
|
|
2453
|
+
if (p !== void 0 && p.kind === "pow") {
|
|
2454
|
+
i++;
|
|
2455
|
+
return powerExactScale(base, p.n);
|
|
2456
|
+
}
|
|
2457
|
+
return base;
|
|
2458
|
+
};
|
|
2459
|
+
const product = (denominator) => {
|
|
2460
|
+
let scale = factor();
|
|
2461
|
+
while (isOp("*") || denominator && isOp("/")) {
|
|
2462
|
+
i++;
|
|
2463
|
+
scale = multiplyExactScales(scale, factor());
|
|
2464
|
+
}
|
|
2465
|
+
return scale;
|
|
2466
|
+
};
|
|
2467
|
+
const expression = () => {
|
|
2468
|
+
const top = product(false);
|
|
2469
|
+
if (!isOp("/")) return top;
|
|
2470
|
+
i++;
|
|
2471
|
+
return divideExactScales(top, product(true));
|
|
2472
|
+
};
|
|
2473
|
+
const result = expression();
|
|
2474
|
+
if (i !== tokens.length) fail();
|
|
2475
|
+
return result;
|
|
2476
|
+
}
|
|
2477
|
+
|
|
2478
|
+
// src/types/unit/unit-table.ts
|
|
2479
|
+
var SI_PREFIX_LIST = [
|
|
2480
|
+
["da", "deca", 1, false],
|
|
2481
|
+
["h", "hecto", 2, false],
|
|
2482
|
+
["k", "kilo", 3, true],
|
|
2483
|
+
["M", "mega", 6, true],
|
|
2484
|
+
["G", "giga", 9, true],
|
|
2485
|
+
["T", "tera", 12, true],
|
|
2486
|
+
["P", "peta", 15, true],
|
|
2487
|
+
["E", "exa", 18, true],
|
|
2488
|
+
["Z", "zetta", 21, true],
|
|
2489
|
+
["Y", "yotta", 24, true],
|
|
2490
|
+
["R", "ronna", 27, true],
|
|
2491
|
+
["Q", "quetta", 30, true],
|
|
2492
|
+
["d", "deci", -1, false],
|
|
2493
|
+
["c", "centi", -2, false],
|
|
2494
|
+
["m", "milli", -3, true],
|
|
2495
|
+
["u", "micro", -6, true],
|
|
2496
|
+
["n", "nano", -9, true],
|
|
2497
|
+
["p", "pico", -12, true],
|
|
2498
|
+
["f", "femto", -15, true],
|
|
2499
|
+
["a", "atto", -18, true],
|
|
2500
|
+
["z", "zepto", -21, true],
|
|
2501
|
+
["y", "yocto", -24, true],
|
|
2502
|
+
["r", "ronto", -27, true],
|
|
2503
|
+
["q", "quecto", -30, true]
|
|
2504
|
+
];
|
|
2505
|
+
var IEC_PREFIX_LIST = [
|
|
2506
|
+
["Ki", "kibi", 1],
|
|
2507
|
+
["Mi", "mebi", 2],
|
|
2508
|
+
["Gi", "gibi", 3],
|
|
2509
|
+
["Ti", "tebi", 4],
|
|
2510
|
+
["Pi", "pebi", 5],
|
|
2511
|
+
["Ei", "exi", 6],
|
|
2512
|
+
["Zi", "zebi", 7],
|
|
2513
|
+
["Yi", "yobi", 8]
|
|
2514
|
+
];
|
|
2515
|
+
function prefixSet(entries) {
|
|
2516
|
+
const set2 = { "": { radix: 10, power: 0, scientific: true } };
|
|
2517
|
+
for (const [name2, power, scientific, radix] of entries) {
|
|
2518
|
+
set2[name2] = Object.freeze({ radix: radix ?? 10, power, scientific });
|
|
2519
|
+
}
|
|
2520
|
+
return Object.freeze(set2);
|
|
2521
|
+
}
|
|
2522
|
+
var siShort = (scale, keep = () => true) => prefixSet(
|
|
2523
|
+
SI_PREFIX_LIST.filter(([, , p]) => keep(p)).map(
|
|
2524
|
+
([short, , p, sci]) => [short, p * scale, sci]
|
|
2525
|
+
)
|
|
2526
|
+
);
|
|
2527
|
+
var siLong = (keep = () => true) => prefixSet(
|
|
2528
|
+
SI_PREFIX_LIST.filter(([, , p]) => keep(p)).map(([, long, p, sci]) => [long, p, sci])
|
|
2529
|
+
);
|
|
2530
|
+
var upToYotta = (p) => p >= 3 && p <= 24;
|
|
2531
|
+
var UNIT_PREFIX_SETS = Object.freeze({
|
|
2532
|
+
NONE: prefixSet([]),
|
|
2533
|
+
SHORT: siShort(1),
|
|
2534
|
+
LONG: siLong(),
|
|
2535
|
+
SHORTLONG: Object.freeze({ ...siShort(1), ...siLong() }),
|
|
2536
|
+
SQUARED: siShort(2),
|
|
2537
|
+
CUBIC: siShort(3),
|
|
2538
|
+
BINARY_SHORT: Object.freeze({
|
|
2539
|
+
...siShort(1, upToYotta),
|
|
2540
|
+
...prefixSet(IEC_PREFIX_LIST.map(([short, , p]) => [short, p, true, 1024]))
|
|
2541
|
+
}),
|
|
2542
|
+
BINARY_LONG: Object.freeze({
|
|
2543
|
+
...siLong(upToYotta),
|
|
2544
|
+
...prefixSet(IEC_PREFIX_LIST.map(([, long, p]) => [long, p, true, 1024]))
|
|
2545
|
+
}),
|
|
2546
|
+
BTU: prefixSet([["MM", 6, true]]),
|
|
2547
|
+
SHORT_UP_ONLY: siShort(1, (p) => p >= 3)
|
|
2548
|
+
});
|
|
2549
|
+
function unitPrefixExactScale(prefix) {
|
|
2550
|
+
return powerExactScale(ratioExactScale(prefix.radix), prefix.power);
|
|
2551
|
+
}
|
|
2552
|
+
function getUnitPrefix(unit, name2) {
|
|
2553
|
+
const row = getUnitRow(unit);
|
|
2554
|
+
if (row === void 0) return void 0;
|
|
2555
|
+
const set2 = UNIT_PREFIX_SETS[row.prefixes];
|
|
2556
|
+
return Object.prototype.hasOwnProperty.call(set2, name2) ? set2[name2] : void 0;
|
|
2557
|
+
}
|
|
2558
|
+
var NAMED_SCALES = Object.freeze({
|
|
2559
|
+
/** International inch, International Yard and Pound Agreement (1959). */
|
|
2560
|
+
inch: "0.0254",
|
|
2561
|
+
foot: "12*inch",
|
|
2562
|
+
yard: "3*foot",
|
|
2563
|
+
mile: "5280*foot",
|
|
2564
|
+
/** International avoirdupois pound, International Yard and Pound Agreement (1959). */
|
|
2565
|
+
pound: "0.45359237",
|
|
2566
|
+
/** Standard acceleration of gravity, 3rd CGPM (1901). */
|
|
2567
|
+
standard_gravity: "9.80665",
|
|
2568
|
+
/** Pound-force: one pound times standard gravity. */
|
|
2569
|
+
lbf: "pound*standard_gravity",
|
|
2570
|
+
/** US gallon: 231 cubic inches. */
|
|
2571
|
+
us_gallon: "231*inch^3",
|
|
2572
|
+
us_fluid_ounce: "us_gallon/128",
|
|
2573
|
+
/** Julian year, 365.25 days (IAU). */
|
|
2574
|
+
julian_year: "365.25*86400",
|
|
2575
|
+
/** Speed of light in vacuum, exact in the SI. */
|
|
2576
|
+
speed_of_light: "299792458",
|
|
2577
|
+
/** Astronomical unit, IAU 2012 Resolution B2. */
|
|
2578
|
+
astronomical_unit: "149597870700",
|
|
2579
|
+
/** Standard atmosphere, 10th CGPM (1954). */
|
|
2580
|
+
standard_atmosphere: "101325",
|
|
2581
|
+
/** International Table calorie (1956). */
|
|
2582
|
+
calorie_IT: "4.1868"
|
|
2583
|
+
});
|
|
2584
|
+
var UNIT_ROWS = Object.freeze({
|
|
2585
|
+
meter: { base: "LENGTH", prefixes: "LONG", scale: "1" },
|
|
2586
|
+
inch: { base: "LENGTH", prefixes: "NONE", scale: "inch" },
|
|
2587
|
+
foot: { base: "LENGTH", prefixes: "NONE", scale: "foot" },
|
|
2588
|
+
yard: { base: "LENGTH", prefixes: "NONE", scale: "yard" },
|
|
2589
|
+
mile: { base: "LENGTH", prefixes: "NONE", scale: "mile" },
|
|
2590
|
+
link: { base: "LENGTH", prefixes: "NONE", scale: "0.66*foot" },
|
|
2591
|
+
// Gunter link, 0.66 ft (international foot)
|
|
2592
|
+
rod: { base: "LENGTH", prefixes: "NONE", scale: "16.5*foot" },
|
|
2593
|
+
// 16.5 ft (international foot)
|
|
2594
|
+
chain: { base: "LENGTH", prefixes: "NONE", scale: "66*foot" },
|
|
2595
|
+
// 66 ft (international foot)
|
|
2596
|
+
angstrom: { base: "LENGTH", prefixes: "NONE", scale: "1e-10" },
|
|
2597
|
+
astronomicalUnit: { base: "LENGTH", prefixes: "NONE", scale: "astronomical_unit" },
|
|
2598
|
+
// IAU 2012 Resolution B2
|
|
2599
|
+
lightyear: { base: "LENGTH", prefixes: "NONE", scale: "speed_of_light*julian_year" },
|
|
2600
|
+
// c × Julian year (IAU)
|
|
2601
|
+
ly: { base: "LENGTH", prefixes: "SHORT_UP_ONLY", scale: "speed_of_light*julian_year" },
|
|
2602
|
+
// c × Julian year (IAU)
|
|
2603
|
+
parsec: { base: "LENGTH", prefixes: "LONG", scale: "648000*astronomical_unit/pi" },
|
|
2604
|
+
// IAU 2015 Resolution B2: 648000/π au
|
|
2605
|
+
pc: { base: "LENGTH", prefixes: "SHORT_UP_ONLY", scale: "648000*astronomical_unit/pi" },
|
|
2606
|
+
// IAU 2015 Resolution B2: 648000/π au
|
|
2607
|
+
nauticalMile: { base: "LENGTH", prefixes: "NONE", scale: "1852" },
|
|
2608
|
+
fathom: { base: "LENGTH", prefixes: "NONE", scale: "6*foot" },
|
|
2609
|
+
// 6 ft
|
|
2610
|
+
furlong: { base: "LENGTH", prefixes: "NONE", scale: "660*foot" },
|
|
2611
|
+
// 660 ft (1/8 mile)
|
|
2612
|
+
point: { base: "LENGTH", prefixes: "NONE", scale: "inch/72" },
|
|
2613
|
+
// 1/72 inch (PostScript point)
|
|
2614
|
+
pica: { base: "LENGTH", prefixes: "NONE", scale: "inch/6" },
|
|
2615
|
+
// 12 points = 1/6 inch
|
|
2616
|
+
m: { base: "LENGTH", prefixes: "SHORT", scale: "1" },
|
|
2617
|
+
in: { base: "LENGTH", prefixes: "NONE", scale: "inch" },
|
|
2618
|
+
ft: { base: "LENGTH", prefixes: "NONE", scale: "foot" },
|
|
2619
|
+
yd: { base: "LENGTH", prefixes: "NONE", scale: "yard" },
|
|
2620
|
+
mi: { base: "LENGTH", prefixes: "NONE", scale: "mile" },
|
|
2621
|
+
li: { base: "LENGTH", prefixes: "NONE", scale: "0.66*foot" },
|
|
2622
|
+
rd: { base: "LENGTH", prefixes: "NONE", scale: "16.5*foot" },
|
|
2623
|
+
// 16.5 ft (international foot)
|
|
2624
|
+
ch: { base: "LENGTH", prefixes: "NONE", scale: "66*foot" },
|
|
2625
|
+
// 66 ft
|
|
2626
|
+
mil: { base: "LENGTH", prefixes: "NONE", scale: "0.001*inch" },
|
|
2627
|
+
// 1/1000 inch
|
|
2628
|
+
m2: { base: "SURFACE", prefixes: "SQUARED", scale: "1" },
|
|
2629
|
+
sqin: { base: "SURFACE", prefixes: "NONE", scale: "inch^2" },
|
|
2630
|
+
sqft: { base: "SURFACE", prefixes: "NONE", scale: "foot^2" },
|
|
2631
|
+
sqyd: { base: "SURFACE", prefixes: "NONE", scale: "yard^2" },
|
|
2632
|
+
sqmi: { base: "SURFACE", prefixes: "NONE", scale: "mile^2" },
|
|
2633
|
+
sqrd: { base: "SURFACE", prefixes: "NONE", scale: "272.25*foot^2" },
|
|
2634
|
+
// (16.5 ft)^2
|
|
2635
|
+
sqch: { base: "SURFACE", prefixes: "NONE", scale: "4356*foot^2" },
|
|
2636
|
+
// (66 ft)^2
|
|
2637
|
+
sqmil: { base: "SURFACE", prefixes: "NONE", scale: "1e-6*inch^2" },
|
|
2638
|
+
acre: { base: "SURFACE", prefixes: "NONE", scale: "43560*foot^2" },
|
|
2639
|
+
// 43 560 ft^2 (international acre)
|
|
2640
|
+
hectare: { base: "SURFACE", prefixes: "NONE", scale: "1e4" },
|
|
2641
|
+
m3: { base: "VOLUME", prefixes: "CUBIC", scale: "1" },
|
|
2642
|
+
L: { base: "VOLUME", prefixes: "SHORT", scale: "1e-3" },
|
|
2643
|
+
l: { base: "VOLUME", prefixes: "SHORT", scale: "1e-3" },
|
|
2644
|
+
litre: { base: "VOLUME", prefixes: "LONG", scale: "1e-3" },
|
|
2645
|
+
cuin: { base: "VOLUME", prefixes: "NONE", scale: "inch^3" },
|
|
2646
|
+
cuft: { base: "VOLUME", prefixes: "NONE", scale: "foot^3" },
|
|
2647
|
+
cuyd: { base: "VOLUME", prefixes: "NONE", scale: "yard^3" },
|
|
2648
|
+
teaspoon: { base: "VOLUME", prefixes: "NONE", scale: "5e-6" },
|
|
2649
|
+
// metric teaspoon, 5 mL (not the US customary 4.93 mL)
|
|
2650
|
+
tablespoon: { base: "VOLUME", prefixes: "NONE", scale: "15e-6" },
|
|
2651
|
+
// metric tablespoon, 15 mL (not the US customary 14.79 mL)
|
|
2652
|
+
drop: { base: "VOLUME", prefixes: "NONE", scale: "5e-8" },
|
|
2653
|
+
// 0.05 mL (medical convention)
|
|
2654
|
+
gtt: { base: "VOLUME", prefixes: "NONE", scale: "5e-8" },
|
|
2655
|
+
// 0.05 mL (medical convention)
|
|
2656
|
+
minim: { base: "VOLUME", prefixes: "NONE", scale: "us_fluid_ounce/480" },
|
|
2657
|
+
// 1/480 US fl oz
|
|
2658
|
+
fluiddram: { base: "VOLUME", prefixes: "NONE", scale: "us_fluid_ounce/8" },
|
|
2659
|
+
// 1/8 US fl oz
|
|
2660
|
+
fluidounce: { base: "VOLUME", prefixes: "NONE", scale: "us_fluid_ounce" },
|
|
2661
|
+
gill: { base: "VOLUME", prefixes: "NONE", scale: "4*us_fluid_ounce" },
|
|
2662
|
+
// 4 US fl oz
|
|
2663
|
+
cc: { base: "VOLUME", prefixes: "NONE", scale: "1e-6" },
|
|
2664
|
+
cup: { base: "VOLUME", prefixes: "NONE", scale: "8*us_fluid_ounce" },
|
|
2665
|
+
// US customary cup, 8 US fl oz
|
|
2666
|
+
pint: { base: "VOLUME", prefixes: "NONE", scale: "16*us_fluid_ounce" },
|
|
2667
|
+
// US liquid pint
|
|
2668
|
+
quart: { base: "VOLUME", prefixes: "NONE", scale: "32*us_fluid_ounce" },
|
|
2669
|
+
// US liquid quart
|
|
2670
|
+
gallon: { base: "VOLUME", prefixes: "NONE", scale: "us_gallon" },
|
|
2671
|
+
// US gallon, 231 in^3
|
|
2672
|
+
beerbarrel: { base: "VOLUME", prefixes: "NONE", scale: "31*us_gallon" },
|
|
2673
|
+
// 31 US gal
|
|
2674
|
+
oilbarrel: { base: "VOLUME", prefixes: "NONE", scale: "42*us_gallon" },
|
|
2675
|
+
// 42 US gal
|
|
2676
|
+
hogshead: { base: "VOLUME", prefixes: "NONE", scale: "63*us_gallon" },
|
|
2677
|
+
// 63 US gal
|
|
2678
|
+
g: { base: "MASS", prefixes: "SHORT", scale: "1e-3" },
|
|
2679
|
+
gram: { base: "MASS", prefixes: "LONG", scale: "1e-3" },
|
|
2680
|
+
ton: { base: "MASS", prefixes: "SHORT", scale: "2000*pound" },
|
|
2681
|
+
// US short ton, 2000 lb
|
|
2682
|
+
t: { base: "MASS", prefixes: "SHORT", scale: "1000" },
|
|
2683
|
+
tonne: { base: "MASS", prefixes: "LONG", scale: "1000" },
|
|
2684
|
+
grain: { base: "MASS", prefixes: "NONE", scale: "pound/7000" },
|
|
2685
|
+
// 1/7000 lb
|
|
2686
|
+
dram: { base: "MASS", prefixes: "NONE", scale: "pound/256" },
|
|
2687
|
+
// avoirdupois dram, 1/256 lb
|
|
2688
|
+
ounce: { base: "MASS", prefixes: "NONE", scale: "pound/16" },
|
|
2689
|
+
// avoirdupois ounce
|
|
2690
|
+
poundmass: { base: "MASS", prefixes: "NONE", scale: "pound" },
|
|
2691
|
+
hundredweight: { base: "MASS", prefixes: "NONE", scale: "100*pound" },
|
|
2692
|
+
// US short hundredweight, 100 lb
|
|
2693
|
+
stick: { base: "MASS", prefixes: "NONE", scale: "0.115" },
|
|
2694
|
+
// butter stick (as in mathjs)
|
|
2695
|
+
stone: { base: "MASS", prefixes: "NONE", scale: "14*pound" },
|
|
2696
|
+
// 14 lb
|
|
2697
|
+
gr: { base: "MASS", prefixes: "NONE", scale: "pound/7000" },
|
|
2698
|
+
dr: { base: "MASS", prefixes: "NONE", scale: "pound/256" },
|
|
2699
|
+
oz: { base: "MASS", prefixes: "NONE", scale: "pound/16" },
|
|
2700
|
+
lbm: { base: "MASS", prefixes: "NONE", scale: "pound" },
|
|
2701
|
+
cwt: { base: "MASS", prefixes: "NONE", scale: "100*pound" },
|
|
2702
|
+
s: { base: "TIME", prefixes: "SHORT", scale: "1" },
|
|
2703
|
+
min: { base: "TIME", prefixes: "NONE", scale: "60" },
|
|
2704
|
+
h: { base: "TIME", prefixes: "NONE", scale: "3600" },
|
|
2705
|
+
second: { base: "TIME", prefixes: "LONG", scale: "1" },
|
|
2706
|
+
sec: { base: "TIME", prefixes: "LONG", scale: "1" },
|
|
2707
|
+
minute: { base: "TIME", prefixes: "NONE", scale: "60" },
|
|
2708
|
+
hour: { base: "TIME", prefixes: "NONE", scale: "3600" },
|
|
2709
|
+
day: { base: "TIME", prefixes: "NONE", scale: "86400" },
|
|
2710
|
+
week: { base: "TIME", prefixes: "NONE", scale: "7*86400" },
|
|
2711
|
+
month: { base: "TIME", prefixes: "NONE", scale: "julian_year/12" },
|
|
2712
|
+
// 1/12 Julian year
|
|
2713
|
+
year: { base: "TIME", prefixes: "NONE", scale: "julian_year" },
|
|
2714
|
+
// Julian year
|
|
2715
|
+
decade: { base: "TIME", prefixes: "NONE", scale: "10*julian_year" },
|
|
2716
|
+
// 10 Julian years
|
|
2717
|
+
century: { base: "TIME", prefixes: "NONE", scale: "100*julian_year" },
|
|
2718
|
+
// 100 Julian years
|
|
2719
|
+
millennium: { base: "TIME", prefixes: "NONE", scale: "1000*julian_year" },
|
|
2720
|
+
// 1000 Julian years
|
|
2721
|
+
hertz: { base: "FREQUENCY", prefixes: "LONG", scale: "1", name: "Hertz", reciprocal: true },
|
|
2722
|
+
Hz: { base: "FREQUENCY", prefixes: "SHORT", scale: "1", reciprocal: true },
|
|
2723
|
+
rad: { base: "ANGLE", prefixes: "SHORT", scale: "1" },
|
|
2724
|
+
radian: { base: "ANGLE", prefixes: "LONG", scale: "1" },
|
|
2725
|
+
deg: { base: "ANGLE", prefixes: "SHORT", scale: "pi/180" },
|
|
2726
|
+
degree: { base: "ANGLE", prefixes: "LONG", scale: "pi/180" },
|
|
2727
|
+
grad: { base: "ANGLE", prefixes: "SHORT", scale: "pi/200" },
|
|
2728
|
+
gradian: { base: "ANGLE", prefixes: "LONG", scale: "pi/200" },
|
|
2729
|
+
cycle: { base: "ANGLE", prefixes: "NONE", scale: "2*pi" },
|
|
2730
|
+
// one turn, 2π rad
|
|
2731
|
+
arcsec: { base: "ANGLE", prefixes: "NONE", scale: "pi/648000" },
|
|
2732
|
+
arcmin: { base: "ANGLE", prefixes: "NONE", scale: "pi/10800" },
|
|
2733
|
+
A: { base: "CURRENT", prefixes: "SHORT", scale: "1" },
|
|
2734
|
+
ampere: { base: "CURRENT", prefixes: "LONG", scale: "1" },
|
|
2735
|
+
K: { base: "TEMPERATURE", prefixes: "SHORT", scale: "1" },
|
|
2736
|
+
degC: { base: "TEMPERATURE", prefixes: "SHORT", scale: "1", offset: "273.15" },
|
|
2737
|
+
// K = °C + 273.15
|
|
2738
|
+
degF: { base: "TEMPERATURE", prefixes: "SHORT", scale: "5/9", offset: "459.67" },
|
|
2739
|
+
// K = (°F + 459.67) × 5/9
|
|
2740
|
+
degR: { base: "TEMPERATURE", prefixes: "SHORT", scale: "5/9" },
|
|
2741
|
+
// K = °R × 5/9
|
|
2742
|
+
kelvin: { base: "TEMPERATURE", prefixes: "LONG", scale: "1" },
|
|
2743
|
+
celsius: { base: "TEMPERATURE", prefixes: "LONG", scale: "1", offset: "273.15" },
|
|
2744
|
+
fahrenheit: { base: "TEMPERATURE", prefixes: "LONG", scale: "5/9", offset: "459.67" },
|
|
2745
|
+
rankine: { base: "TEMPERATURE", prefixes: "LONG", scale: "5/9" },
|
|
2746
|
+
mol: { base: "AMOUNT_OF_SUBSTANCE", prefixes: "SHORT", scale: "1" },
|
|
2747
|
+
mole: { base: "AMOUNT_OF_SUBSTANCE", prefixes: "LONG", scale: "1" },
|
|
2748
|
+
cd: { base: "LUMINOUS_INTENSITY", prefixes: "SHORT", scale: "1" },
|
|
2749
|
+
candela: { base: "LUMINOUS_INTENSITY", prefixes: "LONG", scale: "1" },
|
|
2750
|
+
sr: { base: "SOLID_ANGLE", prefixes: "NONE", scale: "1" },
|
|
2751
|
+
steradian: { base: "SOLID_ANGLE", prefixes: "LONG", scale: "1" },
|
|
2752
|
+
N: { base: "FORCE", prefixes: "SHORT", scale: "1" },
|
|
2753
|
+
newton: { base: "FORCE", prefixes: "LONG", scale: "1" },
|
|
2754
|
+
dyn: { base: "FORCE", prefixes: "SHORT", scale: "1e-5" },
|
|
2755
|
+
dyne: { base: "FORCE", prefixes: "LONG", scale: "1e-5" },
|
|
2756
|
+
lbf: { base: "FORCE", prefixes: "NONE", scale: "lbf" },
|
|
2757
|
+
poundforce: { base: "FORCE", prefixes: "NONE", scale: "lbf" },
|
|
2758
|
+
kip: { base: "FORCE", prefixes: "LONG", scale: "1000*lbf" },
|
|
2759
|
+
// 1000 lbf
|
|
2760
|
+
kilogramforce: { base: "FORCE", prefixes: "NONE", scale: "standard_gravity" },
|
|
2761
|
+
// standard gravity × 1 kg
|
|
2762
|
+
J: { base: "ENERGY", prefixes: "SHORT", scale: "1" },
|
|
2763
|
+
joule: { base: "ENERGY", prefixes: "LONG", scale: "1" },
|
|
2764
|
+
erg: { base: "ENERGY", prefixes: "SHORTLONG", scale: "1e-7" },
|
|
2765
|
+
Wh: { base: "ENERGY", prefixes: "SHORT", scale: "3600" },
|
|
2766
|
+
cal: { base: "ENERGY", prefixes: "SHORT", scale: "4.184" },
|
|
2767
|
+
// thermochemical calorie, 4.184 J exactly (NIST SP 811). Not cal_IT = 4.1868 J
|
|
2768
|
+
calorie: { base: "ENERGY", prefixes: "LONG", scale: "4.184" },
|
|
2769
|
+
// thermochemical calorie
|
|
2770
|
+
BTU: { base: "ENERGY", prefixes: "BTU", scale: "1000*calorie_IT*pound/1.8" },
|
|
2771
|
+
// International Table BTU: cal_IT × (lb/g) / 1.8
|
|
2772
|
+
eV: { base: "ENERGY", prefixes: "SHORT", scale: "1.602176634e-19" },
|
|
2773
|
+
// e × 1 V, exact since the 2019 SI
|
|
2774
|
+
electronvolt: { base: "ENERGY", prefixes: "LONG", scale: "1.602176634e-19" },
|
|
2775
|
+
W: { base: "POWER", prefixes: "SHORT", scale: "1" },
|
|
2776
|
+
watt: { base: "POWER", prefixes: "LONG", scale: "1" },
|
|
2777
|
+
hp: { base: "POWER", prefixes: "NONE", scale: "550*foot*lbf" },
|
|
2778
|
+
// mechanical horsepower, 550 ft·lbf/s
|
|
2779
|
+
VAR: { base: "POWER", prefixes: "SHORT", scale: "1", imaginary: true },
|
|
2780
|
+
// reactive power: the value is the imaginary unit times this scale
|
|
2781
|
+
VA: { base: "POWER", prefixes: "SHORT", scale: "1" },
|
|
2782
|
+
Pa: { base: "PRESSURE", prefixes: "SHORT", scale: "1" },
|
|
2783
|
+
psi: { base: "PRESSURE", prefixes: "NONE", scale: "lbf/inch^2" },
|
|
2784
|
+
// lbf/in^2
|
|
2785
|
+
atm: { base: "PRESSURE", prefixes: "NONE", scale: "standard_atmosphere" },
|
|
2786
|
+
// standard atmosphere
|
|
2787
|
+
bar: { base: "PRESSURE", prefixes: "SHORTLONG", scale: "1e5" },
|
|
2788
|
+
torr: { base: "PRESSURE", prefixes: "NONE", scale: "standard_atmosphere/760" },
|
|
2789
|
+
// 1/760 atm (exact)
|
|
2790
|
+
mmHg: { base: "PRESSURE", prefixes: "NONE", scale: "13.5951*standard_gravity" },
|
|
2791
|
+
// conventional mmHg: 13.5951 g/cm^3 × g_n × 1 mm = 133.322387415 Pa (NIST SP 811). Not the torr
|
|
2792
|
+
mmH2O: { base: "PRESSURE", prefixes: "NONE", scale: "standard_gravity" },
|
|
2793
|
+
// conventional: 1000 kg/m^3 × g_n × 1 mm
|
|
2794
|
+
cmH2O: { base: "PRESSURE", prefixes: "NONE", scale: "10*standard_gravity" },
|
|
2795
|
+
// conventional: 1000 kg/m^3 × g_n × 1 cm
|
|
2796
|
+
coulomb: { base: "ELECTRIC_CHARGE", prefixes: "LONG", scale: "1" },
|
|
2797
|
+
C: { base: "ELECTRIC_CHARGE", prefixes: "SHORT", scale: "1" },
|
|
2798
|
+
farad: { base: "ELECTRIC_CAPACITANCE", prefixes: "LONG", scale: "1" },
|
|
2799
|
+
F: { base: "ELECTRIC_CAPACITANCE", prefixes: "SHORT", scale: "1" },
|
|
2800
|
+
volt: { base: "ELECTRIC_POTENTIAL", prefixes: "LONG", scale: "1" },
|
|
2801
|
+
V: { base: "ELECTRIC_POTENTIAL", prefixes: "SHORT", scale: "1" },
|
|
2802
|
+
ohm: { base: "ELECTRIC_RESISTANCE", prefixes: "SHORTLONG", scale: "1" },
|
|
2803
|
+
henry: { base: "ELECTRIC_INDUCTANCE", prefixes: "LONG", scale: "1" },
|
|
2804
|
+
H: { base: "ELECTRIC_INDUCTANCE", prefixes: "SHORT", scale: "1" },
|
|
2805
|
+
siemens: { base: "ELECTRIC_CONDUCTANCE", prefixes: "LONG", scale: "1" },
|
|
2806
|
+
S: { base: "ELECTRIC_CONDUCTANCE", prefixes: "SHORT", scale: "1" },
|
|
2807
|
+
weber: { base: "MAGNETIC_FLUX", prefixes: "LONG", scale: "1" },
|
|
2808
|
+
Wb: { base: "MAGNETIC_FLUX", prefixes: "SHORT", scale: "1" },
|
|
2809
|
+
tesla: { base: "MAGNETIC_FLUX_DENSITY", prefixes: "LONG", scale: "1" },
|
|
2810
|
+
T: { base: "MAGNETIC_FLUX_DENSITY", prefixes: "SHORT", scale: "1" },
|
|
2811
|
+
b: { base: "BIT", prefixes: "BINARY_SHORT", scale: "1" },
|
|
2812
|
+
// bit: its own BIT dimension (storage), not ln 2 nat
|
|
2813
|
+
bits: { base: "BIT", prefixes: "BINARY_LONG", scale: "1" },
|
|
2814
|
+
B: { base: "BIT", prefixes: "BINARY_SHORT", scale: "8" },
|
|
2815
|
+
// byte, 8 bits
|
|
2816
|
+
bytes: { base: "BIT", prefixes: "BINARY_LONG", scale: "8" }
|
|
2817
|
+
});
|
|
2818
|
+
var UNIT_ROW_ALIASES = Object.freeze({
|
|
2819
|
+
meters: "meter",
|
|
2820
|
+
// Astronomical / nautical / typography aliases (B-5 port). Lowercase
|
|
2821
|
+
// 'au' is deliberately ABSENT: it collides with the atomic unit of
|
|
2822
|
+
// length (Bohr radius, ~5.29e-11 m), 21 orders of magnitude smaller.
|
|
2823
|
+
AU: "astronomicalUnit",
|
|
2824
|
+
astronomicalUnits: "astronomicalUnit",
|
|
2825
|
+
lightyears: "lightyear",
|
|
2826
|
+
parsecs: "parsec",
|
|
2827
|
+
nmi: "nauticalMile",
|
|
2828
|
+
nauticalMiles: "nauticalMile",
|
|
2829
|
+
fathoms: "fathom",
|
|
2830
|
+
furlongs: "furlong",
|
|
2831
|
+
points: "point",
|
|
2832
|
+
picas: "pica",
|
|
2833
|
+
inches: "inch",
|
|
2834
|
+
feet: "foot",
|
|
2835
|
+
yards: "yard",
|
|
2836
|
+
miles: "mile",
|
|
2837
|
+
links: "link",
|
|
2838
|
+
rods: "rod",
|
|
2839
|
+
chains: "chain",
|
|
2840
|
+
angstroms: "angstrom",
|
|
2841
|
+
lt: "l",
|
|
2842
|
+
litres: "litre",
|
|
2843
|
+
liter: "litre",
|
|
2844
|
+
liters: "litre",
|
|
2845
|
+
teaspoons: "teaspoon",
|
|
2846
|
+
tablespoons: "tablespoon",
|
|
2847
|
+
minims: "minim",
|
|
2848
|
+
fldr: "fluiddram",
|
|
2849
|
+
fluiddrams: "fluiddram",
|
|
2850
|
+
floz: "fluidounce",
|
|
2851
|
+
fluidounces: "fluidounce",
|
|
2852
|
+
gi: "gill",
|
|
2853
|
+
gills: "gill",
|
|
2854
|
+
cp: "cup",
|
|
2855
|
+
cups: "cup",
|
|
2856
|
+
pt: "pint",
|
|
2857
|
+
pints: "pint",
|
|
2858
|
+
qt: "quart",
|
|
2859
|
+
quarts: "quart",
|
|
2860
|
+
gal: "gallon",
|
|
2861
|
+
gallons: "gallon",
|
|
2862
|
+
bbl: "beerbarrel",
|
|
2863
|
+
beerbarrels: "beerbarrel",
|
|
2864
|
+
obl: "oilbarrel",
|
|
2865
|
+
oilbarrels: "oilbarrel",
|
|
2866
|
+
hogsheads: "hogshead",
|
|
2867
|
+
gtts: "gtt",
|
|
2868
|
+
grams: "gram",
|
|
2869
|
+
tons: "ton",
|
|
2870
|
+
tonnes: "tonne",
|
|
2871
|
+
grains: "grain",
|
|
2872
|
+
drams: "dram",
|
|
2873
|
+
ounces: "ounce",
|
|
2874
|
+
poundmasses: "poundmass",
|
|
2875
|
+
hundredweights: "hundredweight",
|
|
2876
|
+
sticks: "stick",
|
|
2877
|
+
lb: "lbm",
|
|
2878
|
+
lbs: "lbm",
|
|
2879
|
+
kips: "kip",
|
|
2880
|
+
kgf: "kilogramforce",
|
|
2881
|
+
acres: "acre",
|
|
2882
|
+
hectares: "hectare",
|
|
2883
|
+
sqfeet: "sqft",
|
|
2884
|
+
sqyard: "sqyd",
|
|
2885
|
+
sqmile: "sqmi",
|
|
2886
|
+
sqmiles: "sqmi",
|
|
2887
|
+
mmhg: "mmHg",
|
|
2888
|
+
mmh2o: "mmH2O",
|
|
2889
|
+
cmh2o: "cmH2O",
|
|
2890
|
+
seconds: "second",
|
|
2891
|
+
secs: "second",
|
|
2892
|
+
minutes: "minute",
|
|
2893
|
+
mins: "minute",
|
|
2894
|
+
hours: "hour",
|
|
2895
|
+
hr: "hour",
|
|
2896
|
+
hrs: "hour",
|
|
2897
|
+
days: "day",
|
|
2898
|
+
weeks: "week",
|
|
2899
|
+
months: "month",
|
|
2900
|
+
years: "year",
|
|
2901
|
+
decades: "decade",
|
|
2902
|
+
centuries: "century",
|
|
2903
|
+
millennia: "millennium",
|
|
2904
|
+
hertz: "hertz",
|
|
2905
|
+
radians: "radian",
|
|
2906
|
+
degrees: "degree",
|
|
2907
|
+
gradians: "gradian",
|
|
2908
|
+
cycles: "cycle",
|
|
2909
|
+
arcsecond: "arcsec",
|
|
2910
|
+
arcseconds: "arcsec",
|
|
2911
|
+
arcminute: "arcmin",
|
|
2912
|
+
arcminutes: "arcmin",
|
|
2913
|
+
BTUs: "BTU",
|
|
2914
|
+
watts: "watt",
|
|
2915
|
+
joules: "joule",
|
|
2916
|
+
amperes: "ampere",
|
|
2917
|
+
amps: "ampere",
|
|
2918
|
+
amp: "ampere",
|
|
2919
|
+
coulombs: "coulomb",
|
|
2920
|
+
volts: "volt",
|
|
2921
|
+
ohms: "ohm",
|
|
2922
|
+
farads: "farad",
|
|
2923
|
+
webers: "weber",
|
|
2924
|
+
teslas: "tesla",
|
|
2925
|
+
electronvolts: "electronvolt",
|
|
2926
|
+
moles: "mole",
|
|
2927
|
+
bit: "bits",
|
|
2928
|
+
byte: "bytes",
|
|
2929
|
+
calories: "calorie"
|
|
2930
|
+
});
|
|
2931
|
+
var namedCache = /* @__PURE__ */ new Map();
|
|
2932
|
+
function namedExactScale(name2) {
|
|
2933
|
+
const cached = namedCache.get(name2);
|
|
2934
|
+
if (cached !== void 0) return cached;
|
|
2935
|
+
if (!Object.prototype.hasOwnProperty.call(NAMED_SCALES, name2)) return void 0;
|
|
2936
|
+
const scale = readScaleExpression(NAMED_SCALES[name2], namedExactScale);
|
|
2937
|
+
namedCache.set(name2, scale);
|
|
2938
|
+
return scale;
|
|
2939
|
+
}
|
|
2940
|
+
function readUnitScale(expression) {
|
|
2941
|
+
return readScaleExpression(expression, namedExactScale);
|
|
2942
|
+
}
|
|
2943
|
+
function getUnitRow(name2) {
|
|
2944
|
+
const own = Object.prototype.hasOwnProperty;
|
|
2945
|
+
if (own.call(UNIT_ROWS, name2)) return UNIT_ROWS[name2];
|
|
2946
|
+
if (own.call(UNIT_ROW_ALIASES, name2)) return UNIT_ROWS[UNIT_ROW_ALIASES[name2]];
|
|
2947
|
+
return void 0;
|
|
2948
|
+
}
|
|
2949
|
+
function unitRowExactScale(name2) {
|
|
2950
|
+
const row = getUnitRow(name2);
|
|
2951
|
+
return row === void 0 ? void 0 : readUnitScale(row.scale);
|
|
2952
|
+
}
|
|
2953
|
+
function unitRowValue(name2) {
|
|
2954
|
+
const scale = unitRowExactScale(name2);
|
|
2955
|
+
return scale === void 0 ? void 0 : exactScaleToNumber(scale);
|
|
2956
|
+
}
|
|
2957
|
+
function unitRowExactOffset(name2) {
|
|
2958
|
+
const row = getUnitRow(name2);
|
|
2959
|
+
if (row === void 0) return void 0;
|
|
2960
|
+
return row.offset === void 0 ? ratioExactScale(0) : readUnitScale(row.offset);
|
|
2961
|
+
}
|
|
2962
|
+
|
|
2151
2963
|
// src/types/unit/Unit.ts
|
|
2964
|
+
var UNIT_ZERO_SCALE = ratioExactScale(0);
|
|
2965
|
+
function exactOffsetShift(from, to) {
|
|
2966
|
+
if (from.exact === void 0 || to.exact === void 0) return null;
|
|
2967
|
+
return addExactScales(
|
|
2968
|
+
multiplyExactScales(from.exact, from.exactOffset ?? UNIT_ZERO_SCALE),
|
|
2969
|
+
multiplyExactScales(ratioExactScale(-1), to.exact, to.exactOffset ?? UNIT_ZERO_SCALE)
|
|
2970
|
+
);
|
|
2971
|
+
}
|
|
2972
|
+
function attachExactScale(def, exact, exactOffset) {
|
|
2973
|
+
Object.defineProperty(def, "exact", {
|
|
2974
|
+
value: exact,
|
|
2975
|
+
enumerable: false,
|
|
2976
|
+
writable: true,
|
|
2977
|
+
configurable: true
|
|
2978
|
+
});
|
|
2979
|
+
Object.defineProperty(def, "exactOffset", {
|
|
2980
|
+
value: exactOffset,
|
|
2981
|
+
enumerable: false,
|
|
2982
|
+
writable: true,
|
|
2983
|
+
configurable: true
|
|
2984
|
+
});
|
|
2985
|
+
}
|
|
2986
|
+
function liveExactSI(unit) {
|
|
2987
|
+
const exact = unit._exactSI;
|
|
2988
|
+
if (exact === void 0 || typeof unit.value !== "number") return void 0;
|
|
2989
|
+
return unit.value === roundExactScale(exact) ? exact : void 0;
|
|
2990
|
+
}
|
|
2991
|
+
var prefixScales = /* @__PURE__ */ new WeakMap();
|
|
2992
|
+
function prefixExactScale(prefix) {
|
|
2993
|
+
let scale = prefixScales.get(prefix);
|
|
2994
|
+
if (scale === void 0) {
|
|
2995
|
+
scale = Number.isFinite(prefix.value) ? exactScaleOf(prefix.value) : null;
|
|
2996
|
+
prefixScales.set(prefix, scale);
|
|
2997
|
+
}
|
|
2998
|
+
return scale;
|
|
2999
|
+
}
|
|
3000
|
+
var definitionIds = /* @__PURE__ */ new WeakMap();
|
|
3001
|
+
var nextDefinitionId = 0;
|
|
3002
|
+
function identityOf(def) {
|
|
3003
|
+
let id = definitionIds.get(def);
|
|
3004
|
+
if (id === void 0) {
|
|
3005
|
+
id = nextDefinitionId++;
|
|
3006
|
+
definitionIds.set(def, id);
|
|
3007
|
+
}
|
|
3008
|
+
return id;
|
|
3009
|
+
}
|
|
3010
|
+
var UNIT_LIST_SCALE_CACHE_LIMIT = 1024;
|
|
3011
|
+
var unitListScales = /* @__PURE__ */ new Map();
|
|
2152
3012
|
function normalizeDegreeSymbols(s) {
|
|
2153
3013
|
return s.replace(/°C/g, "degC").replace(/°F/g, "degF").replace(/°/g, "deg");
|
|
2154
3014
|
}
|
|
@@ -2197,6 +3057,72 @@ var createUnitClass = /* @__PURE__ */ factory(
|
|
|
2197
3057
|
const toNumber = number2;
|
|
2198
3058
|
const fixPrefixDefault = false;
|
|
2199
3059
|
const skipAutomaticSimplificationDefault = true;
|
|
3060
|
+
function bigNumberFromText(text2) {
|
|
3061
|
+
const parse = BigNumber2.parse;
|
|
3062
|
+
return typeof parse === "function" ? parse.call(BigNumber2, text2) : new BigNumber2(text2);
|
|
3063
|
+
}
|
|
3064
|
+
function exactToBigNumber(scale) {
|
|
3065
|
+
const powerOfPi = irrationalPower(scale, "pi");
|
|
3066
|
+
if (Object.keys(scale.irrationals).length !== (powerOfPi === 0 ? 0 : 1)) return void 0;
|
|
3067
|
+
let v = bigNumberFromText(scale.num.toString()).div(bigNumberFromText(scale.den.toString()));
|
|
3068
|
+
const pi = BIGNUMBER_PI;
|
|
3069
|
+
for (let k = 0; k < Math.abs(powerOfPi); k++) v = powerOfPi > 0 ? v.times(pi) : v.div(pi);
|
|
3070
|
+
return v;
|
|
3071
|
+
}
|
|
3072
|
+
function simplestReading(value, scale) {
|
|
3073
|
+
if (value === 0) return void 0;
|
|
3074
|
+
const start = applyExactScale(value, scale, true);
|
|
3075
|
+
if (typeof start !== "number" || !Number.isFinite(start) || start === 0) return void 0;
|
|
3076
|
+
const view = new DataView(new ArrayBuffer(8));
|
|
3077
|
+
view.setFloat64(0, start);
|
|
3078
|
+
const bits = view.getBigInt64(0);
|
|
3079
|
+
let best;
|
|
3080
|
+
let bestLength = Infinity;
|
|
3081
|
+
for (const step of [0n, -1n, 1n, -2n, 2n, -3n, 3n, -4n, 4n]) {
|
|
3082
|
+
view.setBigInt64(0, bits + step);
|
|
3083
|
+
const r = view.getFloat64(0);
|
|
3084
|
+
if (!Number.isFinite(r) || Math.sign(r) !== Math.sign(start)) continue;
|
|
3085
|
+
if (roundExactScale(multiplyExactScales(exactScaleOf(r), scale)) !== value) continue;
|
|
3086
|
+
const length = String(r).length;
|
|
3087
|
+
if (length < bestLength) {
|
|
3088
|
+
best = r;
|
|
3089
|
+
bestLength = length;
|
|
3090
|
+
}
|
|
3091
|
+
}
|
|
3092
|
+
return best;
|
|
3093
|
+
}
|
|
3094
|
+
function addExactShift(unit, value, shift) {
|
|
3095
|
+
if (typeof value === "number") {
|
|
3096
|
+
if (!Number.isFinite(value)) return void 0;
|
|
3097
|
+
let normalized = binaryExactScale(value);
|
|
3098
|
+
const scale = unit.exactScale();
|
|
3099
|
+
const reading = scale === null ? void 0 : simplestReading(value, scale);
|
|
3100
|
+
if (reading !== void 0) normalized = multiplyExactScales(exactScaleOf(reading), scale);
|
|
3101
|
+
const sum = addExactScales(normalized, shift);
|
|
3102
|
+
return sum === null ? void 0 : roundExactScale(sum);
|
|
3103
|
+
}
|
|
3104
|
+
const s = exactAs(shift, typeOf(value));
|
|
3105
|
+
return s === void 0 ? void 0 : addScalar2(value, s);
|
|
3106
|
+
}
|
|
3107
|
+
function exactAs(scale, type) {
|
|
3108
|
+
if (type === "Fraction") {
|
|
3109
|
+
return isRationalScale(scale) ? new Fraction2(scale.num, scale.den) : void 0;
|
|
3110
|
+
}
|
|
3111
|
+
if (type === "BigNumber") return exactToBigNumber(scale);
|
|
3112
|
+
return void 0;
|
|
3113
|
+
}
|
|
3114
|
+
function applyExactScale(value, scale, divide) {
|
|
3115
|
+
if (typeof value === "number") {
|
|
3116
|
+
if (!Number.isFinite(value) || value === 0) return void 0;
|
|
3117
|
+
const x = divide ? binaryExactScale(value) : exactScaleOf(value);
|
|
3118
|
+
return roundExactScale(
|
|
3119
|
+
divide ? divideExactScales(x, scale) : multiplyExactScales(x, scale)
|
|
3120
|
+
);
|
|
3121
|
+
}
|
|
3122
|
+
const factor = exactAs(scale, typeOf(value));
|
|
3123
|
+
if (factor === void 0) return void 0;
|
|
3124
|
+
return divide ? divideScalar2(value, factor) : multiplyScalar2(value, factor);
|
|
3125
|
+
}
|
|
2200
3126
|
const Unit2 = function(value, valuelessUnit) {
|
|
2201
3127
|
if (!(this instanceof Unit2)) {
|
|
2202
3128
|
throw new Error("Constructor must be called with the new operator");
|
|
@@ -2225,7 +3151,14 @@ var createUnitClass = /* @__PURE__ */ factory(
|
|
|
2225
3151
|
"Second parameter in Unit constructor must be a string or valueless Unit"
|
|
2226
3152
|
);
|
|
2227
3153
|
}
|
|
2228
|
-
this.
|
|
3154
|
+
this._exactSI = void 0;
|
|
3155
|
+
const scale = typeof value === "number" && Number.isFinite(value) && value !== 0 && this.units.length > 0 ? this.exactScale() : null;
|
|
3156
|
+
if (scale !== null) {
|
|
3157
|
+
this._exactSI = multiplyExactScales(exactScaleOf(value), scale);
|
|
3158
|
+
this.value = roundExactScale(this._exactSI);
|
|
3159
|
+
} else {
|
|
3160
|
+
this.value = this._normalize(value);
|
|
3161
|
+
}
|
|
2229
3162
|
};
|
|
2230
3163
|
Object.defineProperty(Unit2, "name", { value: "Unit" });
|
|
2231
3164
|
Unit2.prototype.constructor = Unit2;
|
|
@@ -2463,6 +3396,7 @@ var createUnitClass = /* @__PURE__ */ factory(
|
|
|
2463
3396
|
unit.fixPrefix = this.fixPrefix;
|
|
2464
3397
|
unit.skipAutomaticSimplification = this.skipAutomaticSimplification;
|
|
2465
3398
|
unit.value = clone(this.value);
|
|
3399
|
+
unit._exactSI = this._exactSI;
|
|
2466
3400
|
unit.dimensions = this.dimensions.slice(0);
|
|
2467
3401
|
unit.units = [];
|
|
2468
3402
|
for (let i = 0; i < this.units.length; i++) {
|
|
@@ -2486,10 +3420,47 @@ var createUnitClass = /* @__PURE__ */ factory(
|
|
|
2486
3420
|
}
|
|
2487
3421
|
return this.units.length > 1 || Math.abs(this.units[0].power - 1) > 1e-15;
|
|
2488
3422
|
};
|
|
3423
|
+
Unit2.prototype.exactScale = function() {
|
|
3424
|
+
let key = "";
|
|
3425
|
+
for (const component of this.units) {
|
|
3426
|
+
key += `${identityOf(component.unit)}:${identityOf(component.prefix)}^${component.power};`;
|
|
3427
|
+
}
|
|
3428
|
+
const cached = unitListScales.get(key);
|
|
3429
|
+
if (cached !== void 0) return cached;
|
|
3430
|
+
const scale = unitListExactScale(this);
|
|
3431
|
+
unitListScales.set(key, scale);
|
|
3432
|
+
if (unitListScales.size > UNIT_LIST_SCALE_CACHE_LIMIT) {
|
|
3433
|
+
unitListScales.delete(unitListScales.keys().next().value);
|
|
3434
|
+
}
|
|
3435
|
+
return scale;
|
|
3436
|
+
};
|
|
3437
|
+
function unitListExactScale(unit) {
|
|
3438
|
+
let scale = UNIT_EXACT_SCALE;
|
|
3439
|
+
for (const component of unit.units) {
|
|
3440
|
+
const unitScale = component.unit.exact;
|
|
3441
|
+
const prefixScale = prefixExactScale(component.prefix);
|
|
3442
|
+
if (unitScale === void 0 || prefixScale === null || !Number.isInteger(component.power)) {
|
|
3443
|
+
return null;
|
|
3444
|
+
}
|
|
3445
|
+
scale = multiplyExactScales(
|
|
3446
|
+
scale,
|
|
3447
|
+
powerExactScale(multiplyExactScales(unitScale, prefixScale), component.power)
|
|
3448
|
+
);
|
|
3449
|
+
}
|
|
3450
|
+
return scale;
|
|
3451
|
+
}
|
|
3452
|
+
Unit2.exactScale = function(valuelessUnit) {
|
|
3453
|
+
return Unit2.parse(valuelessUnit).exactScale();
|
|
3454
|
+
};
|
|
2489
3455
|
Unit2.prototype._normalize = function(value) {
|
|
2490
3456
|
if (value === null || value === void 0 || this.units.length === 0) {
|
|
2491
3457
|
return value ?? null;
|
|
2492
3458
|
}
|
|
3459
|
+
const scale = this.exactScale();
|
|
3460
|
+
if (scale !== null) {
|
|
3461
|
+
const exact = applyExactScale(value, scale, false);
|
|
3462
|
+
if (exact !== void 0) return exact;
|
|
3463
|
+
}
|
|
2493
3464
|
let res = value;
|
|
2494
3465
|
const convert = Unit2._getNumberConverter(typeOf(value));
|
|
2495
3466
|
for (let i = 0; i < this.units.length; i++) {
|
|
@@ -2504,6 +3475,18 @@ var createUnitClass = /* @__PURE__ */ factory(
|
|
|
2504
3475
|
if (value === null || value === void 0 || this.units.length === 0) {
|
|
2505
3476
|
return value ?? null;
|
|
2506
3477
|
}
|
|
3478
|
+
const scale = this.exactScale();
|
|
3479
|
+
if (scale !== null) {
|
|
3480
|
+
if (this._exactSI !== void 0 && this._exactSI !== null) {
|
|
3481
|
+
const exactSiNumber = roundExactScale(this._exactSI);
|
|
3482
|
+
if (typeof value === "number" && value === exactSiNumber) {
|
|
3483
|
+
return roundExactScale(divideExactScales(this._exactSI, scale));
|
|
3484
|
+
}
|
|
3485
|
+
this._exactSI = void 0;
|
|
3486
|
+
}
|
|
3487
|
+
const exact = applyExactScale(value, scale, true);
|
|
3488
|
+
if (exact !== void 0) return exact;
|
|
3489
|
+
}
|
|
2507
3490
|
let res = value;
|
|
2508
3491
|
const convert = Unit2._getNumberConverter(typeOf(value));
|
|
2509
3492
|
for (let i = 0; i < this.units.length; i++) {
|
|
@@ -2583,8 +3566,10 @@ var createUnitClass = /* @__PURE__ */ factory(
|
|
|
2583
3566
|
const valThis = this.value === null ? this._normalize(one(other.value)) : this.value;
|
|
2584
3567
|
const valOther = other.value === null ? other._normalize(one(this.value)) : other.value;
|
|
2585
3568
|
res.value = multiplyScalar2(valThis, valOther);
|
|
3569
|
+
res._exactSI = void 0;
|
|
2586
3570
|
} else {
|
|
2587
3571
|
res.value = null;
|
|
3572
|
+
res._exactSI = void 0;
|
|
2588
3573
|
}
|
|
2589
3574
|
if (isUnit(_other)) {
|
|
2590
3575
|
res.skipAutomaticSimplification = false;
|
|
@@ -2614,8 +3599,10 @@ var createUnitClass = /* @__PURE__ */ factory(
|
|
|
2614
3599
|
const valThis = this.value === null ? this._normalize(one(other.value)) : this.value;
|
|
2615
3600
|
const valOther = other.value === null ? other._normalize(one(this.value)) : other.value;
|
|
2616
3601
|
res.value = divideScalar2(valThis, valOther);
|
|
3602
|
+
res._exactSI = void 0;
|
|
2617
3603
|
} else {
|
|
2618
3604
|
res.value = null;
|
|
3605
|
+
res._exactSI = void 0;
|
|
2619
3606
|
}
|
|
2620
3607
|
if (isUnit(_other)) {
|
|
2621
3608
|
res.skipAutomaticSimplification = false;
|
|
@@ -2635,8 +3622,10 @@ var createUnitClass = /* @__PURE__ */ factory(
|
|
|
2635
3622
|
}
|
|
2636
3623
|
if (res.value !== null) {
|
|
2637
3624
|
res.value = pow2(res.value, p);
|
|
3625
|
+
res._exactSI = void 0;
|
|
2638
3626
|
} else {
|
|
2639
3627
|
res.value = null;
|
|
3628
|
+
res._exactSI = void 0;
|
|
2640
3629
|
}
|
|
2641
3630
|
res.skipAutomaticSimplification = false;
|
|
2642
3631
|
return getNumericIfUnitless(res);
|
|
@@ -2726,9 +3715,10 @@ var createUnitClass = /* @__PURE__ */ factory(
|
|
|
2726
3715
|
ret.value = abs2(ret.value);
|
|
2727
3716
|
} else {
|
|
2728
3717
|
const convert = ret._numberConverter();
|
|
2729
|
-
const
|
|
2730
|
-
const
|
|
2731
|
-
const
|
|
3718
|
+
const def = ret.units[0].unit;
|
|
3719
|
+
const exactOffset = def.exact === void 0 ? void 0 : multiplyExactScales(def.exact, def.exactOffset ?? UNIT_ZERO_SCALE);
|
|
3720
|
+
const valueType = typeOf(ret.value);
|
|
3721
|
+
const unitOffset = exactOffset === void 0 ? multiplyScalar2(convert(def.value), convert(def.offset)) : valueType === "number" ? roundExactScale(exactOffset) : exactAs(exactOffset, valueType) ?? multiplyScalar2(convert(def.value), convert(def.offset));
|
|
2732
3722
|
ret.value = subtractScalar3(abs2(addScalar2(ret.value, unitOffset)), unitOffset);
|
|
2733
3723
|
}
|
|
2734
3724
|
}
|
|
@@ -2760,7 +3750,28 @@ var createUnitClass = /* @__PURE__ */ factory(
|
|
|
2760
3750
|
}
|
|
2761
3751
|
if (this.value === null || this._isDerived() || this.units.length === 0 || other.units.length === 0 || this.units[0].unit.offset === other.units[0].unit.offset) {
|
|
2762
3752
|
other.value = clone(value);
|
|
3753
|
+
other._exactSI = liveExactSI(this);
|
|
2763
3754
|
} else {
|
|
3755
|
+
const shift = exactOffsetShift(this.units[0].unit, other.units[0].unit);
|
|
3756
|
+
const exactSI = liveExactSI(this);
|
|
3757
|
+
if (shift !== null && exactSI) {
|
|
3758
|
+
const sum = addExactScales(exactSI, shift);
|
|
3759
|
+
if (sum !== null) {
|
|
3760
|
+
other._exactSI = sum;
|
|
3761
|
+
other.value = roundExactScale(sum);
|
|
3762
|
+
other.fixPrefix = true;
|
|
3763
|
+
other.skipAutomaticSimplification = true;
|
|
3764
|
+
return other;
|
|
3765
|
+
}
|
|
3766
|
+
}
|
|
3767
|
+
const shifted = shift === null ? void 0 : addExactShift(this, value, shift);
|
|
3768
|
+
if (shifted !== void 0) {
|
|
3769
|
+
other.value = shifted;
|
|
3770
|
+
other._exactSI = void 0;
|
|
3771
|
+
other.fixPrefix = true;
|
|
3772
|
+
other.skipAutomaticSimplification = true;
|
|
3773
|
+
return other;
|
|
3774
|
+
}
|
|
2764
3775
|
const convert = Unit2._getNumberConverter(typeOf(value));
|
|
2765
3776
|
const thisUnitValue = this.units[0].unit.value;
|
|
2766
3777
|
const thisNominalOffset = this.units[0].unit.offset;
|
|
@@ -3092,183 +4103,30 @@ var createUnitClass = /* @__PURE__ */ factory(
|
|
|
3092
4103
|
ret.push(x);
|
|
3093
4104
|
return ret;
|
|
3094
4105
|
};
|
|
3095
|
-
const PREFIXES = {
|
|
3096
|
-
|
|
3097
|
-
|
|
3098
|
-
|
|
3099
|
-
|
|
3100
|
-
|
|
3101
|
-
|
|
3102
|
-
|
|
3103
|
-
|
|
3104
|
-
|
|
3105
|
-
|
|
3106
|
-
|
|
3107
|
-
|
|
3108
|
-
|
|
3109
|
-
Z: { name: "Z", value: 1e21, scientific: true },
|
|
3110
|
-
Y: { name: "Y", value: 1e24, scientific: true },
|
|
3111
|
-
R: { name: "R", value: 1e27, scientific: true },
|
|
3112
|
-
Q: { name: "Q", value: 1e30, scientific: true },
|
|
3113
|
-
d: { name: "d", value: 0.1, scientific: false },
|
|
3114
|
-
c: { name: "c", value: 0.01, scientific: false },
|
|
3115
|
-
m: { name: "m", value: 1e-3, scientific: true },
|
|
3116
|
-
u: { name: "u", value: 1e-6, scientific: true },
|
|
3117
|
-
n: { name: "n", value: 1e-9, scientific: true },
|
|
3118
|
-
p: { name: "p", value: 1e-12, scientific: true },
|
|
3119
|
-
f: { name: "f", value: 1e-15, scientific: true },
|
|
3120
|
-
a: { name: "a", value: 1e-18, scientific: true },
|
|
3121
|
-
z: { name: "z", value: 1e-21, scientific: true },
|
|
3122
|
-
y: { name: "y", value: 1e-24, scientific: true },
|
|
3123
|
-
r: { name: "r", value: 1e-27, scientific: true },
|
|
3124
|
-
q: { name: "q", value: 1e-30, scientific: true }
|
|
3125
|
-
},
|
|
3126
|
-
LONG: {
|
|
3127
|
-
"": { name: "", value: 1, scientific: true },
|
|
3128
|
-
deca: { name: "deca", value: 10, scientific: false },
|
|
3129
|
-
hecto: { name: "hecto", value: 100, scientific: false },
|
|
3130
|
-
kilo: { name: "kilo", value: 1e3, scientific: true },
|
|
3131
|
-
mega: { name: "mega", value: 1e6, scientific: true },
|
|
3132
|
-
giga: { name: "giga", value: 1e9, scientific: true },
|
|
3133
|
-
tera: { name: "tera", value: 1e12, scientific: true },
|
|
3134
|
-
peta: { name: "peta", value: 1e15, scientific: true },
|
|
3135
|
-
exa: { name: "exa", value: 1e18, scientific: true },
|
|
3136
|
-
zetta: { name: "zetta", value: 1e21, scientific: true },
|
|
3137
|
-
yotta: { name: "yotta", value: 1e24, scientific: true },
|
|
3138
|
-
ronna: { name: "ronna", value: 1e27, scientific: true },
|
|
3139
|
-
quetta: { name: "quetta", value: 1e30, scientific: true },
|
|
3140
|
-
deci: { name: "deci", value: 0.1, scientific: false },
|
|
3141
|
-
centi: { name: "centi", value: 0.01, scientific: false },
|
|
3142
|
-
milli: { name: "milli", value: 1e-3, scientific: true },
|
|
3143
|
-
micro: { name: "micro", value: 1e-6, scientific: true },
|
|
3144
|
-
nano: { name: "nano", value: 1e-9, scientific: true },
|
|
3145
|
-
pico: { name: "pico", value: 1e-12, scientific: true },
|
|
3146
|
-
femto: { name: "femto", value: 1e-15, scientific: true },
|
|
3147
|
-
atto: { name: "atto", value: 1e-18, scientific: true },
|
|
3148
|
-
zepto: { name: "zepto", value: 1e-21, scientific: true },
|
|
3149
|
-
yocto: { name: "yocto", value: 1e-24, scientific: true },
|
|
3150
|
-
ronto: { name: "ronto", value: 1e-27, scientific: true },
|
|
3151
|
-
quecto: { name: "quecto", value: 1e-30, scientific: true }
|
|
3152
|
-
},
|
|
3153
|
-
SQUARED: {
|
|
3154
|
-
"": { name: "", value: 1, scientific: true },
|
|
3155
|
-
da: { name: "da", value: 100, scientific: false },
|
|
3156
|
-
h: { name: "h", value: 1e4, scientific: false },
|
|
3157
|
-
k: { name: "k", value: 1e6, scientific: true },
|
|
3158
|
-
M: { name: "M", value: 1e12, scientific: true },
|
|
3159
|
-
G: { name: "G", value: 1e18, scientific: true },
|
|
3160
|
-
T: { name: "T", value: 1e24, scientific: true },
|
|
3161
|
-
P: { name: "P", value: 1e30, scientific: true },
|
|
3162
|
-
E: { name: "E", value: 1e36, scientific: true },
|
|
3163
|
-
Z: { name: "Z", value: 1e42, scientific: true },
|
|
3164
|
-
Y: { name: "Y", value: 1e48, scientific: true },
|
|
3165
|
-
R: { name: "R", value: 1e54, scientific: true },
|
|
3166
|
-
Q: { name: "Q", value: 1e60, scientific: true },
|
|
3167
|
-
d: { name: "d", value: 0.01, scientific: false },
|
|
3168
|
-
c: { name: "c", value: 1e-4, scientific: false },
|
|
3169
|
-
m: { name: "m", value: 1e-6, scientific: true },
|
|
3170
|
-
u: { name: "u", value: 1e-12, scientific: true },
|
|
3171
|
-
n: { name: "n", value: 1e-18, scientific: true },
|
|
3172
|
-
p: { name: "p", value: 1e-24, scientific: true },
|
|
3173
|
-
f: { name: "f", value: 1e-30, scientific: true },
|
|
3174
|
-
a: { name: "a", value: 1e-36, scientific: true },
|
|
3175
|
-
z: { name: "z", value: 1e-42, scientific: true },
|
|
3176
|
-
y: { name: "y", value: 1e-48, scientific: true },
|
|
3177
|
-
r: { name: "r", value: 1e-54, scientific: true },
|
|
3178
|
-
q: { name: "q", value: 1e-60, scientific: true }
|
|
3179
|
-
},
|
|
3180
|
-
CUBIC: {
|
|
3181
|
-
"": { name: "", value: 1, scientific: true },
|
|
3182
|
-
da: { name: "da", value: 1e3, scientific: false },
|
|
3183
|
-
h: { name: "h", value: 1e6, scientific: false },
|
|
3184
|
-
k: { name: "k", value: 1e9, scientific: true },
|
|
3185
|
-
M: { name: "M", value: 1e18, scientific: true },
|
|
3186
|
-
G: { name: "G", value: 1e27, scientific: true },
|
|
3187
|
-
T: { name: "T", value: 1e36, scientific: true },
|
|
3188
|
-
P: { name: "P", value: 1e45, scientific: true },
|
|
3189
|
-
E: { name: "E", value: 1e54, scientific: true },
|
|
3190
|
-
Z: { name: "Z", value: 1e63, scientific: true },
|
|
3191
|
-
Y: { name: "Y", value: 1e72, scientific: true },
|
|
3192
|
-
R: { name: "R", value: 1e81, scientific: true },
|
|
3193
|
-
Q: { name: "Q", value: 1e90, scientific: true },
|
|
3194
|
-
d: { name: "d", value: 1e-3, scientific: false },
|
|
3195
|
-
c: { name: "c", value: 1e-6, scientific: false },
|
|
3196
|
-
m: { name: "m", value: 1e-9, scientific: true },
|
|
3197
|
-
u: { name: "u", value: 1e-18, scientific: true },
|
|
3198
|
-
n: { name: "n", value: 1e-27, scientific: true },
|
|
3199
|
-
p: { name: "p", value: 1e-36, scientific: true },
|
|
3200
|
-
f: { name: "f", value: 1e-45, scientific: true },
|
|
3201
|
-
a: { name: "a", value: 1e-54, scientific: true },
|
|
3202
|
-
z: { name: "z", value: 1e-63, scientific: true },
|
|
3203
|
-
y: { name: "y", value: 1e-72, scientific: true },
|
|
3204
|
-
r: { name: "r", value: 1e-81, scientific: true },
|
|
3205
|
-
q: { name: "q", value: 1e-90, scientific: true }
|
|
3206
|
-
},
|
|
3207
|
-
BINARY_SHORT_SI: {
|
|
3208
|
-
"": { name: "", value: 1, scientific: true },
|
|
3209
|
-
k: { name: "k", value: 1e3, scientific: true },
|
|
3210
|
-
M: { name: "M", value: 1e6, scientific: true },
|
|
3211
|
-
G: { name: "G", value: 1e9, scientific: true },
|
|
3212
|
-
T: { name: "T", value: 1e12, scientific: true },
|
|
3213
|
-
P: { name: "P", value: 1e15, scientific: true },
|
|
3214
|
-
E: { name: "E", value: 1e18, scientific: true },
|
|
3215
|
-
Z: { name: "Z", value: 1e21, scientific: true },
|
|
3216
|
-
Y: { name: "Y", value: 1e24, scientific: true }
|
|
3217
|
-
},
|
|
3218
|
-
BINARY_SHORT_IEC: {
|
|
3219
|
-
"": { name: "", value: 1, scientific: true },
|
|
3220
|
-
Ki: { name: "Ki", value: 1024, scientific: true },
|
|
3221
|
-
Mi: { name: "Mi", value: Math.pow(1024, 2), scientific: true },
|
|
3222
|
-
Gi: { name: "Gi", value: Math.pow(1024, 3), scientific: true },
|
|
3223
|
-
Ti: { name: "Ti", value: Math.pow(1024, 4), scientific: true },
|
|
3224
|
-
Pi: { name: "Pi", value: Math.pow(1024, 5), scientific: true },
|
|
3225
|
-
Ei: { name: "Ei", value: Math.pow(1024, 6), scientific: true },
|
|
3226
|
-
Zi: { name: "Zi", value: Math.pow(1024, 7), scientific: true },
|
|
3227
|
-
Yi: { name: "Yi", value: Math.pow(1024, 8), scientific: true }
|
|
3228
|
-
},
|
|
3229
|
-
BINARY_LONG_SI: {
|
|
3230
|
-
"": { name: "", value: 1, scientific: true },
|
|
3231
|
-
kilo: { name: "kilo", value: 1e3, scientific: true },
|
|
3232
|
-
mega: { name: "mega", value: 1e6, scientific: true },
|
|
3233
|
-
giga: { name: "giga", value: 1e9, scientific: true },
|
|
3234
|
-
tera: { name: "tera", value: 1e12, scientific: true },
|
|
3235
|
-
peta: { name: "peta", value: 1e15, scientific: true },
|
|
3236
|
-
exa: { name: "exa", value: 1e18, scientific: true },
|
|
3237
|
-
zetta: { name: "zetta", value: 1e21, scientific: true },
|
|
3238
|
-
yotta: { name: "yotta", value: 1e24, scientific: true }
|
|
3239
|
-
},
|
|
3240
|
-
BINARY_LONG_IEC: {
|
|
3241
|
-
"": { name: "", value: 1, scientific: true },
|
|
3242
|
-
kibi: { name: "kibi", value: 1024, scientific: true },
|
|
3243
|
-
mebi: { name: "mebi", value: Math.pow(1024, 2), scientific: true },
|
|
3244
|
-
gibi: { name: "gibi", value: Math.pow(1024, 3), scientific: true },
|
|
3245
|
-
tebi: { name: "tebi", value: Math.pow(1024, 4), scientific: true },
|
|
3246
|
-
pebi: { name: "pebi", value: Math.pow(1024, 5), scientific: true },
|
|
3247
|
-
exi: { name: "exi", value: Math.pow(1024, 6), scientific: true },
|
|
3248
|
-
zebi: { name: "zebi", value: Math.pow(1024, 7), scientific: true },
|
|
3249
|
-
yobi: { name: "yobi", value: Math.pow(1024, 8), scientific: true }
|
|
3250
|
-
},
|
|
3251
|
-
BTU: {
|
|
3252
|
-
"": { name: "", value: 1, scientific: true },
|
|
3253
|
-
MM: { name: "MM", value: 1e6, scientific: true }
|
|
4106
|
+
const PREFIXES = {};
|
|
4107
|
+
const prefixTable = (set2, keep = () => true) => {
|
|
4108
|
+
const table = {};
|
|
4109
|
+
for (const name2 of Object.keys(set2)) {
|
|
4110
|
+
const prefix = set2[name2];
|
|
4111
|
+
if (name2 !== "" && !keep(prefix, name2)) continue;
|
|
4112
|
+
const exact = unitPrefixExactScale(prefix);
|
|
4113
|
+
const def = {
|
|
4114
|
+
name: name2,
|
|
4115
|
+
value: roundExactScale(exact),
|
|
4116
|
+
scientific: prefix.scientific
|
|
4117
|
+
};
|
|
4118
|
+
prefixScales.set(def, exact);
|
|
4119
|
+
table[name2] = def;
|
|
3254
4120
|
}
|
|
4121
|
+
return table;
|
|
3255
4122
|
};
|
|
3256
|
-
|
|
3257
|
-
|
|
3258
|
-
|
|
3259
|
-
PREFIXES.
|
|
3260
|
-
|
|
3261
|
-
|
|
3262
|
-
|
|
3263
|
-
G: { name: "G", value: 1e9, scientific: true },
|
|
3264
|
-
T: { name: "T", value: 1e12, scientific: true },
|
|
3265
|
-
P: { name: "P", value: 1e15, scientific: true },
|
|
3266
|
-
E: { name: "E", value: 1e18, scientific: true },
|
|
3267
|
-
Z: { name: "Z", value: 1e21, scientific: true },
|
|
3268
|
-
Y: { name: "Y", value: 1e24, scientific: true },
|
|
3269
|
-
R: { name: "R", value: 1e27, scientific: true },
|
|
3270
|
-
Q: { name: "Q", value: 1e30, scientific: true }
|
|
3271
|
-
};
|
|
4123
|
+
for (const key of Object.keys(UNIT_PREFIX_SETS)) {
|
|
4124
|
+
PREFIXES[key] = prefixTable(UNIT_PREFIX_SETS[key]);
|
|
4125
|
+
}
|
|
4126
|
+
PREFIXES.BINARY_SHORT_SI = prefixTable(UNIT_PREFIX_SETS.BINARY_SHORT, (p) => p.radix === 10);
|
|
4127
|
+
PREFIXES.BINARY_SHORT_IEC = prefixTable(UNIT_PREFIX_SETS.BINARY_SHORT, (p) => p.radix === 1024);
|
|
4128
|
+
PREFIXES.BINARY_LONG_SI = prefixTable(UNIT_PREFIX_SETS.BINARY_LONG, (p) => p.radix === 10);
|
|
4129
|
+
PREFIXES.BINARY_LONG_IEC = prefixTable(UNIT_PREFIX_SETS.BINARY_LONG, (p) => p.radix === 1024);
|
|
3272
4130
|
const BASE_DIMENSIONS = [
|
|
3273
4131
|
"MASS",
|
|
3274
4132
|
"LENGTH",
|
|
@@ -3374,1410 +4232,35 @@ var createUnitClass = /* @__PURE__ */ factory(
|
|
|
3374
4232
|
offset: 0,
|
|
3375
4233
|
dimensions: BASE_DIMENSIONS.map((_x) => 0)
|
|
3376
4234
|
};
|
|
3377
|
-
|
|
3378
|
-
|
|
3379
|
-
|
|
3380
|
-
|
|
3381
|
-
|
|
3382
|
-
|
|
3383
|
-
|
|
3384
|
-
|
|
3385
|
-
|
|
3386
|
-
|
|
3387
|
-
|
|
3388
|
-
|
|
3389
|
-
|
|
3390
|
-
|
|
3391
|
-
|
|
3392
|
-
|
|
3393
|
-
|
|
3394
|
-
|
|
3395
|
-
|
|
3396
|
-
|
|
3397
|
-
|
|
3398
|
-
offset: 0
|
|
3399
|
-
},
|
|
3400
|
-
yard: {
|
|
3401
|
-
name: "yard",
|
|
3402
|
-
base: BASE_UNITS.LENGTH,
|
|
3403
|
-
prefixes: PREFIXES.NONE,
|
|
3404
|
-
value: 0.9144,
|
|
3405
|
-
offset: 0
|
|
3406
|
-
},
|
|
3407
|
-
mile: {
|
|
3408
|
-
name: "mile",
|
|
3409
|
-
base: BASE_UNITS.LENGTH,
|
|
3410
|
-
prefixes: PREFIXES.NONE,
|
|
3411
|
-
value: 1609.344,
|
|
3412
|
-
offset: 0
|
|
3413
|
-
},
|
|
3414
|
-
link: {
|
|
3415
|
-
name: "link",
|
|
3416
|
-
base: BASE_UNITS.LENGTH,
|
|
3417
|
-
prefixes: PREFIXES.NONE,
|
|
3418
|
-
value: 0.201168,
|
|
3419
|
-
offset: 0
|
|
3420
|
-
},
|
|
3421
|
-
rod: {
|
|
3422
|
-
name: "rod",
|
|
3423
|
-
base: BASE_UNITS.LENGTH,
|
|
3424
|
-
prefixes: PREFIXES.NONE,
|
|
3425
|
-
value: 5.0292,
|
|
3426
|
-
offset: 0
|
|
3427
|
-
},
|
|
3428
|
-
chain: {
|
|
3429
|
-
name: "chain",
|
|
3430
|
-
base: BASE_UNITS.LENGTH,
|
|
3431
|
-
prefixes: PREFIXES.NONE,
|
|
3432
|
-
value: 20.1168,
|
|
3433
|
-
offset: 0
|
|
3434
|
-
},
|
|
3435
|
-
angstrom: {
|
|
3436
|
-
name: "angstrom",
|
|
3437
|
-
base: BASE_UNITS.LENGTH,
|
|
3438
|
-
prefixes: PREFIXES.NONE,
|
|
3439
|
-
value: 1e-10,
|
|
3440
|
-
offset: 0
|
|
3441
|
-
},
|
|
3442
|
-
// Astronomical / nautical / typography length units (ported from
|
|
3443
|
-
// upstream mathjs ece1aab0f + 5f360326b — B-5). `ly` and `pc` are
|
|
3444
|
-
// first-class UNITS with SHORT_UP_ONLY prefixes so kpc/Mpc/Mly/Gly
|
|
3445
|
-
// resolve through the prefix system while sub-multiples throw.
|
|
3446
|
-
astronomicalUnit: {
|
|
3447
|
-
name: "astronomicalUnit",
|
|
3448
|
-
base: BASE_UNITS.LENGTH,
|
|
3449
|
-
prefixes: PREFIXES.NONE,
|
|
3450
|
-
value: 149597870700,
|
|
3451
|
-
// IAU 2012 exact definition
|
|
3452
|
-
offset: 0
|
|
3453
|
-
},
|
|
3454
|
-
lightyear: {
|
|
3455
|
-
name: "lightyear",
|
|
3456
|
-
base: BASE_UNITS.LENGTH,
|
|
3457
|
-
prefixes: PREFIXES.NONE,
|
|
3458
|
-
value: 9460730472580800,
|
|
3459
|
-
// Julian year × c (exact)
|
|
3460
|
-
offset: 0
|
|
3461
|
-
},
|
|
3462
|
-
ly: {
|
|
3463
|
-
name: "ly",
|
|
3464
|
-
base: BASE_UNITS.LENGTH,
|
|
3465
|
-
prefixes: PREFIXES.SHORT_UP_ONLY,
|
|
3466
|
-
value: 9460730472580800,
|
|
3467
|
-
offset: 0
|
|
3468
|
-
},
|
|
3469
|
-
parsec: {
|
|
3470
|
-
name: "parsec",
|
|
3471
|
-
base: BASE_UNITS.LENGTH,
|
|
3472
|
-
prefixes: PREFIXES.LONG,
|
|
3473
|
-
// kiloparsec, megaparsec, gigaparsec
|
|
3474
|
-
value: 30856775814913700,
|
|
3475
|
-
// IAU 2015 exact definition
|
|
3476
|
-
offset: 0
|
|
3477
|
-
},
|
|
3478
|
-
pc: {
|
|
3479
|
-
name: "pc",
|
|
3480
|
-
base: BASE_UNITS.LENGTH,
|
|
3481
|
-
prefixes: PREFIXES.SHORT_UP_ONLY,
|
|
3482
|
-
value: 30856775814913700,
|
|
3483
|
-
offset: 0
|
|
3484
|
-
},
|
|
3485
|
-
nauticalMile: {
|
|
3486
|
-
name: "nauticalMile",
|
|
3487
|
-
base: BASE_UNITS.LENGTH,
|
|
3488
|
-
prefixes: PREFIXES.NONE,
|
|
3489
|
-
value: 1852,
|
|
3490
|
-
// exact
|
|
3491
|
-
offset: 0
|
|
3492
|
-
},
|
|
3493
|
-
fathom: {
|
|
3494
|
-
name: "fathom",
|
|
3495
|
-
base: BASE_UNITS.LENGTH,
|
|
3496
|
-
prefixes: PREFIXES.NONE,
|
|
3497
|
-
value: 1.8288,
|
|
3498
|
-
// 6 ft exactly
|
|
3499
|
-
offset: 0
|
|
3500
|
-
},
|
|
3501
|
-
furlong: {
|
|
3502
|
-
name: "furlong",
|
|
3503
|
-
base: BASE_UNITS.LENGTH,
|
|
3504
|
-
prefixes: PREFIXES.NONE,
|
|
3505
|
-
value: 201.168,
|
|
3506
|
-
// 1/8 mile exactly
|
|
3507
|
-
offset: 0
|
|
3508
|
-
},
|
|
3509
|
-
point: {
|
|
3510
|
-
name: "point",
|
|
3511
|
-
base: BASE_UNITS.LENGTH,
|
|
3512
|
-
prefixes: PREFIXES.NONE,
|
|
3513
|
-
value: 0.0254 / 72,
|
|
3514
|
-
// 1/72 inch (PostScript), exact
|
|
3515
|
-
offset: 0
|
|
3516
|
-
},
|
|
3517
|
-
pica: {
|
|
3518
|
-
name: "pica",
|
|
3519
|
-
base: BASE_UNITS.LENGTH,
|
|
3520
|
-
prefixes: PREFIXES.NONE,
|
|
3521
|
-
value: 0.0254 / 6,
|
|
3522
|
-
// 1/6 inch (12 points), exact
|
|
3523
|
-
offset: 0
|
|
3524
|
-
},
|
|
3525
|
-
m: {
|
|
3526
|
-
name: "m",
|
|
3527
|
-
base: BASE_UNITS.LENGTH,
|
|
3528
|
-
prefixes: PREFIXES.SHORT,
|
|
3529
|
-
value: 1,
|
|
3530
|
-
offset: 0
|
|
3531
|
-
},
|
|
3532
|
-
in: {
|
|
3533
|
-
name: "in",
|
|
3534
|
-
base: BASE_UNITS.LENGTH,
|
|
3535
|
-
prefixes: PREFIXES.NONE,
|
|
3536
|
-
value: 0.0254,
|
|
3537
|
-
offset: 0
|
|
3538
|
-
},
|
|
3539
|
-
ft: {
|
|
3540
|
-
name: "ft",
|
|
3541
|
-
base: BASE_UNITS.LENGTH,
|
|
3542
|
-
prefixes: PREFIXES.NONE,
|
|
3543
|
-
value: 0.3048,
|
|
3544
|
-
offset: 0
|
|
3545
|
-
},
|
|
3546
|
-
yd: {
|
|
3547
|
-
name: "yd",
|
|
3548
|
-
base: BASE_UNITS.LENGTH,
|
|
3549
|
-
prefixes: PREFIXES.NONE,
|
|
3550
|
-
value: 0.9144,
|
|
3551
|
-
offset: 0
|
|
3552
|
-
},
|
|
3553
|
-
mi: {
|
|
3554
|
-
name: "mi",
|
|
3555
|
-
base: BASE_UNITS.LENGTH,
|
|
3556
|
-
prefixes: PREFIXES.NONE,
|
|
3557
|
-
value: 1609.344,
|
|
3558
|
-
offset: 0
|
|
3559
|
-
},
|
|
3560
|
-
li: {
|
|
3561
|
-
name: "li",
|
|
3562
|
-
base: BASE_UNITS.LENGTH,
|
|
3563
|
-
prefixes: PREFIXES.NONE,
|
|
3564
|
-
value: 0.201168,
|
|
3565
|
-
offset: 0
|
|
3566
|
-
},
|
|
3567
|
-
rd: {
|
|
3568
|
-
name: "rd",
|
|
3569
|
-
base: BASE_UNITS.LENGTH,
|
|
3570
|
-
prefixes: PREFIXES.NONE,
|
|
3571
|
-
value: 5.02921,
|
|
3572
|
-
offset: 0
|
|
3573
|
-
},
|
|
3574
|
-
ch: {
|
|
3575
|
-
name: "ch",
|
|
3576
|
-
base: BASE_UNITS.LENGTH,
|
|
3577
|
-
prefixes: PREFIXES.NONE,
|
|
3578
|
-
value: 20.1168,
|
|
3579
|
-
offset: 0
|
|
3580
|
-
},
|
|
3581
|
-
mil: {
|
|
3582
|
-
name: "mil",
|
|
3583
|
-
base: BASE_UNITS.LENGTH,
|
|
3584
|
-
prefixes: PREFIXES.NONE,
|
|
3585
|
-
value: 254e-7,
|
|
3586
|
-
offset: 0
|
|
3587
|
-
},
|
|
3588
|
-
// 1/1000 inch
|
|
3589
|
-
// Surface
|
|
3590
|
-
m2: {
|
|
3591
|
-
name: "m2",
|
|
3592
|
-
base: BASE_UNITS.SURFACE,
|
|
3593
|
-
prefixes: PREFIXES.SQUARED,
|
|
3594
|
-
value: 1,
|
|
3595
|
-
offset: 0
|
|
3596
|
-
},
|
|
3597
|
-
sqin: {
|
|
3598
|
-
name: "sqin",
|
|
3599
|
-
base: BASE_UNITS.SURFACE,
|
|
3600
|
-
prefixes: PREFIXES.NONE,
|
|
3601
|
-
value: 64516e-8,
|
|
3602
|
-
offset: 0
|
|
3603
|
-
},
|
|
3604
|
-
// 645.16 mm2
|
|
3605
|
-
sqft: {
|
|
3606
|
-
name: "sqft",
|
|
3607
|
-
base: BASE_UNITS.SURFACE,
|
|
3608
|
-
prefixes: PREFIXES.NONE,
|
|
3609
|
-
value: 0.09290304,
|
|
3610
|
-
offset: 0
|
|
3611
|
-
},
|
|
3612
|
-
// 0.09290304 m2
|
|
3613
|
-
sqyd: {
|
|
3614
|
-
name: "sqyd",
|
|
3615
|
-
base: BASE_UNITS.SURFACE,
|
|
3616
|
-
prefixes: PREFIXES.NONE,
|
|
3617
|
-
value: 0.83612736,
|
|
3618
|
-
offset: 0
|
|
3619
|
-
},
|
|
3620
|
-
// 0.83612736 m2
|
|
3621
|
-
sqmi: {
|
|
3622
|
-
name: "sqmi",
|
|
3623
|
-
base: BASE_UNITS.SURFACE,
|
|
3624
|
-
prefixes: PREFIXES.NONE,
|
|
3625
|
-
value: 2589988110336e-6,
|
|
3626
|
-
offset: 0
|
|
3627
|
-
},
|
|
3628
|
-
// 2.589988110336 km2
|
|
3629
|
-
sqrd: {
|
|
3630
|
-
name: "sqrd",
|
|
3631
|
-
base: BASE_UNITS.SURFACE,
|
|
3632
|
-
prefixes: PREFIXES.NONE,
|
|
3633
|
-
value: 25.29295,
|
|
3634
|
-
offset: 0
|
|
3635
|
-
},
|
|
3636
|
-
// 25.29295 m2
|
|
3637
|
-
sqch: {
|
|
3638
|
-
name: "sqch",
|
|
3639
|
-
base: BASE_UNITS.SURFACE,
|
|
3640
|
-
prefixes: PREFIXES.NONE,
|
|
3641
|
-
value: 404.6873,
|
|
3642
|
-
offset: 0
|
|
3643
|
-
},
|
|
3644
|
-
// 404.6873 m2
|
|
3645
|
-
sqmil: {
|
|
3646
|
-
name: "sqmil",
|
|
3647
|
-
base: BASE_UNITS.SURFACE,
|
|
3648
|
-
prefixes: PREFIXES.NONE,
|
|
3649
|
-
value: 64516e-14,
|
|
3650
|
-
offset: 0
|
|
3651
|
-
},
|
|
3652
|
-
// 6.4516 * 10^-10 m2
|
|
3653
|
-
acre: {
|
|
3654
|
-
name: "acre",
|
|
3655
|
-
base: BASE_UNITS.SURFACE,
|
|
3656
|
-
prefixes: PREFIXES.NONE,
|
|
3657
|
-
value: 4046.86,
|
|
3658
|
-
offset: 0
|
|
3659
|
-
},
|
|
3660
|
-
// 4046.86 m2
|
|
3661
|
-
hectare: {
|
|
3662
|
-
name: "hectare",
|
|
3663
|
-
base: BASE_UNITS.SURFACE,
|
|
3664
|
-
prefixes: PREFIXES.NONE,
|
|
3665
|
-
value: 1e4,
|
|
3666
|
-
offset: 0
|
|
3667
|
-
},
|
|
3668
|
-
// 10000 m2
|
|
3669
|
-
// Volume
|
|
3670
|
-
m3: {
|
|
3671
|
-
name: "m3",
|
|
3672
|
-
base: BASE_UNITS.VOLUME,
|
|
3673
|
-
prefixes: PREFIXES.CUBIC,
|
|
3674
|
-
value: 1,
|
|
3675
|
-
offset: 0
|
|
3676
|
-
},
|
|
3677
|
-
L: {
|
|
3678
|
-
name: "L",
|
|
3679
|
-
base: BASE_UNITS.VOLUME,
|
|
3680
|
-
prefixes: PREFIXES.SHORT,
|
|
3681
|
-
value: 1e-3,
|
|
3682
|
-
offset: 0
|
|
3683
|
-
},
|
|
3684
|
-
// litre
|
|
3685
|
-
l: {
|
|
3686
|
-
name: "l",
|
|
3687
|
-
base: BASE_UNITS.VOLUME,
|
|
3688
|
-
prefixes: PREFIXES.SHORT,
|
|
3689
|
-
value: 1e-3,
|
|
3690
|
-
offset: 0
|
|
3691
|
-
},
|
|
3692
|
-
// litre
|
|
3693
|
-
litre: {
|
|
3694
|
-
name: "litre",
|
|
3695
|
-
base: BASE_UNITS.VOLUME,
|
|
3696
|
-
prefixes: PREFIXES.LONG,
|
|
3697
|
-
value: 1e-3,
|
|
3698
|
-
offset: 0
|
|
3699
|
-
},
|
|
3700
|
-
cuin: {
|
|
3701
|
-
name: "cuin",
|
|
3702
|
-
base: BASE_UNITS.VOLUME,
|
|
3703
|
-
prefixes: PREFIXES.NONE,
|
|
3704
|
-
value: 16387064e-12,
|
|
3705
|
-
offset: 0
|
|
3706
|
-
},
|
|
3707
|
-
// 1.6387064e-5 m3
|
|
3708
|
-
cuft: {
|
|
3709
|
-
name: "cuft",
|
|
3710
|
-
base: BASE_UNITS.VOLUME,
|
|
3711
|
-
prefixes: PREFIXES.NONE,
|
|
3712
|
-
value: 0.028316846592,
|
|
3713
|
-
offset: 0
|
|
3714
|
-
},
|
|
3715
|
-
// 28.316 846 592 L
|
|
3716
|
-
cuyd: {
|
|
3717
|
-
name: "cuyd",
|
|
3718
|
-
base: BASE_UNITS.VOLUME,
|
|
3719
|
-
prefixes: PREFIXES.NONE,
|
|
3720
|
-
value: 0.764554857984,
|
|
3721
|
-
offset: 0
|
|
3722
|
-
},
|
|
3723
|
-
// 764.554 857 984 L
|
|
3724
|
-
teaspoon: {
|
|
3725
|
-
name: "teaspoon",
|
|
3726
|
-
base: BASE_UNITS.VOLUME,
|
|
3727
|
-
prefixes: PREFIXES.NONE,
|
|
3728
|
-
value: 5e-6,
|
|
3729
|
-
offset: 0
|
|
3730
|
-
},
|
|
3731
|
-
// 5 mL
|
|
3732
|
-
tablespoon: {
|
|
3733
|
-
name: "tablespoon",
|
|
3734
|
-
base: BASE_UNITS.VOLUME,
|
|
3735
|
-
prefixes: PREFIXES.NONE,
|
|
3736
|
-
value: 15e-6,
|
|
3737
|
-
offset: 0
|
|
3738
|
-
},
|
|
3739
|
-
// 15 mL
|
|
3740
|
-
// {name: 'cup', base: BASE_UNITS.VOLUME, prefixes: PREFIXES.NONE, value: 0.000240, offset: 0}, // 240 mL // not possible, we have already another cup
|
|
3741
|
-
drop: {
|
|
3742
|
-
name: "drop",
|
|
3743
|
-
base: BASE_UNITS.VOLUME,
|
|
3744
|
-
prefixes: PREFIXES.NONE,
|
|
3745
|
-
value: 5e-8,
|
|
3746
|
-
offset: 0
|
|
3747
|
-
},
|
|
3748
|
-
// 0.05 mL = 5e-8 m3
|
|
3749
|
-
gtt: {
|
|
3750
|
-
name: "gtt",
|
|
3751
|
-
base: BASE_UNITS.VOLUME,
|
|
3752
|
-
prefixes: PREFIXES.NONE,
|
|
3753
|
-
value: 5e-8,
|
|
3754
|
-
offset: 0
|
|
3755
|
-
},
|
|
3756
|
-
// 0.05 mL = 5e-8 m3
|
|
3757
|
-
// Liquid volume
|
|
3758
|
-
minim: {
|
|
3759
|
-
name: "minim",
|
|
3760
|
-
base: BASE_UNITS.VOLUME,
|
|
3761
|
-
prefixes: PREFIXES.NONE,
|
|
3762
|
-
value: 61611519921875e-21,
|
|
3763
|
-
offset: 0
|
|
3764
|
-
},
|
|
3765
|
-
// 1/61440 gallons
|
|
3766
|
-
fluiddram: {
|
|
3767
|
-
name: "fluiddram",
|
|
3768
|
-
base: BASE_UNITS.VOLUME,
|
|
3769
|
-
prefixes: PREFIXES.NONE,
|
|
3770
|
-
value: 36966911953125e-19,
|
|
3771
|
-
offset: 0
|
|
3772
|
-
},
|
|
3773
|
-
// 1/1024 gallons
|
|
3774
|
-
fluidounce: {
|
|
3775
|
-
name: "fluidounce",
|
|
3776
|
-
base: BASE_UNITS.VOLUME,
|
|
3777
|
-
prefixes: PREFIXES.NONE,
|
|
3778
|
-
value: 295735295625e-16,
|
|
3779
|
-
offset: 0
|
|
3780
|
-
},
|
|
3781
|
-
// 1/128 gallons
|
|
3782
|
-
gill: {
|
|
3783
|
-
name: "gill",
|
|
3784
|
-
base: BASE_UNITS.VOLUME,
|
|
3785
|
-
prefixes: PREFIXES.NONE,
|
|
3786
|
-
value: 11829411825e-14,
|
|
3787
|
-
offset: 0
|
|
3788
|
-
},
|
|
3789
|
-
// 1/32 gallons
|
|
3790
|
-
cc: {
|
|
3791
|
-
name: "cc",
|
|
3792
|
-
base: BASE_UNITS.VOLUME,
|
|
3793
|
-
prefixes: PREFIXES.NONE,
|
|
3794
|
-
value: 1e-6,
|
|
3795
|
-
offset: 0
|
|
3796
|
-
},
|
|
3797
|
-
// 1e-6 L
|
|
3798
|
-
cup: {
|
|
3799
|
-
name: "cup",
|
|
3800
|
-
base: BASE_UNITS.VOLUME,
|
|
3801
|
-
prefixes: PREFIXES.NONE,
|
|
3802
|
-
value: 2365882365e-13,
|
|
3803
|
-
offset: 0
|
|
3804
|
-
},
|
|
3805
|
-
// 1/16 gallons
|
|
3806
|
-
pint: {
|
|
3807
|
-
name: "pint",
|
|
3808
|
-
base: BASE_UNITS.VOLUME,
|
|
3809
|
-
prefixes: PREFIXES.NONE,
|
|
3810
|
-
value: 473176473e-12,
|
|
3811
|
-
offset: 0
|
|
3812
|
-
},
|
|
3813
|
-
// 1/8 gallons
|
|
3814
|
-
quart: {
|
|
3815
|
-
name: "quart",
|
|
3816
|
-
base: BASE_UNITS.VOLUME,
|
|
3817
|
-
prefixes: PREFIXES.NONE,
|
|
3818
|
-
value: 946352946e-12,
|
|
3819
|
-
offset: 0
|
|
3820
|
-
},
|
|
3821
|
-
// 1/4 gallons
|
|
3822
|
-
gallon: {
|
|
3823
|
-
name: "gallon",
|
|
3824
|
-
base: BASE_UNITS.VOLUME,
|
|
3825
|
-
prefixes: PREFIXES.NONE,
|
|
3826
|
-
value: 0.003785411784,
|
|
3827
|
-
offset: 0
|
|
3828
|
-
},
|
|
3829
|
-
// 3.785411784 L
|
|
3830
|
-
beerbarrel: {
|
|
3831
|
-
name: "beerbarrel",
|
|
3832
|
-
base: BASE_UNITS.VOLUME,
|
|
3833
|
-
prefixes: PREFIXES.NONE,
|
|
3834
|
-
value: 0.117347765304,
|
|
3835
|
-
offset: 0
|
|
3836
|
-
},
|
|
3837
|
-
// 31 gallons
|
|
3838
|
-
oilbarrel: {
|
|
3839
|
-
name: "oilbarrel",
|
|
3840
|
-
base: BASE_UNITS.VOLUME,
|
|
3841
|
-
prefixes: PREFIXES.NONE,
|
|
3842
|
-
value: 0.158987294928,
|
|
3843
|
-
offset: 0
|
|
3844
|
-
},
|
|
3845
|
-
// 42 gallons
|
|
3846
|
-
hogshead: {
|
|
3847
|
-
name: "hogshead",
|
|
3848
|
-
base: BASE_UNITS.VOLUME,
|
|
3849
|
-
prefixes: PREFIXES.NONE,
|
|
3850
|
-
value: 0.238480942392,
|
|
3851
|
-
offset: 0
|
|
3852
|
-
},
|
|
3853
|
-
// 63 gallons
|
|
3854
|
-
// Mass
|
|
3855
|
-
g: {
|
|
3856
|
-
name: "g",
|
|
3857
|
-
base: BASE_UNITS.MASS,
|
|
3858
|
-
prefixes: PREFIXES.SHORT,
|
|
3859
|
-
value: 1e-3,
|
|
3860
|
-
offset: 0
|
|
3861
|
-
},
|
|
3862
|
-
gram: {
|
|
3863
|
-
name: "gram",
|
|
3864
|
-
base: BASE_UNITS.MASS,
|
|
3865
|
-
prefixes: PREFIXES.LONG,
|
|
3866
|
-
value: 1e-3,
|
|
3867
|
-
offset: 0
|
|
3868
|
-
},
|
|
3869
|
-
ton: {
|
|
3870
|
-
name: "ton",
|
|
3871
|
-
base: BASE_UNITS.MASS,
|
|
3872
|
-
prefixes: PREFIXES.SHORT,
|
|
3873
|
-
value: 907.18474,
|
|
3874
|
-
offset: 0
|
|
3875
|
-
},
|
|
3876
|
-
t: {
|
|
3877
|
-
name: "t",
|
|
3878
|
-
base: BASE_UNITS.MASS,
|
|
3879
|
-
prefixes: PREFIXES.SHORT,
|
|
3880
|
-
value: 1e3,
|
|
3881
|
-
offset: 0
|
|
3882
|
-
},
|
|
3883
|
-
tonne: {
|
|
3884
|
-
name: "tonne",
|
|
3885
|
-
base: BASE_UNITS.MASS,
|
|
3886
|
-
prefixes: PREFIXES.LONG,
|
|
3887
|
-
value: 1e3,
|
|
3888
|
-
offset: 0
|
|
3889
|
-
},
|
|
3890
|
-
grain: {
|
|
3891
|
-
name: "grain",
|
|
3892
|
-
base: BASE_UNITS.MASS,
|
|
3893
|
-
prefixes: PREFIXES.NONE,
|
|
3894
|
-
value: 6479891e-11,
|
|
3895
|
-
offset: 0
|
|
3896
|
-
},
|
|
3897
|
-
dram: {
|
|
3898
|
-
name: "dram",
|
|
3899
|
-
base: BASE_UNITS.MASS,
|
|
3900
|
-
prefixes: PREFIXES.NONE,
|
|
3901
|
-
value: 0.0017718451953125,
|
|
3902
|
-
offset: 0
|
|
3903
|
-
},
|
|
3904
|
-
ounce: {
|
|
3905
|
-
name: "ounce",
|
|
3906
|
-
base: BASE_UNITS.MASS,
|
|
3907
|
-
prefixes: PREFIXES.NONE,
|
|
3908
|
-
value: 0.028349523125,
|
|
3909
|
-
offset: 0
|
|
3910
|
-
},
|
|
3911
|
-
poundmass: {
|
|
3912
|
-
name: "poundmass",
|
|
3913
|
-
base: BASE_UNITS.MASS,
|
|
3914
|
-
prefixes: PREFIXES.NONE,
|
|
3915
|
-
value: 0.45359237,
|
|
3916
|
-
offset: 0
|
|
3917
|
-
},
|
|
3918
|
-
hundredweight: {
|
|
3919
|
-
name: "hundredweight",
|
|
3920
|
-
base: BASE_UNITS.MASS,
|
|
3921
|
-
prefixes: PREFIXES.NONE,
|
|
3922
|
-
value: 45.359237,
|
|
3923
|
-
offset: 0
|
|
3924
|
-
},
|
|
3925
|
-
stick: {
|
|
3926
|
-
name: "stick",
|
|
3927
|
-
base: BASE_UNITS.MASS,
|
|
3928
|
-
prefixes: PREFIXES.NONE,
|
|
3929
|
-
value: 0.115,
|
|
3930
|
-
offset: 0
|
|
3931
|
-
},
|
|
3932
|
-
stone: {
|
|
3933
|
-
name: "stone",
|
|
3934
|
-
base: BASE_UNITS.MASS,
|
|
3935
|
-
prefixes: PREFIXES.NONE,
|
|
3936
|
-
value: 6.35029318,
|
|
3937
|
-
offset: 0
|
|
3938
|
-
},
|
|
3939
|
-
gr: {
|
|
3940
|
-
name: "gr",
|
|
3941
|
-
base: BASE_UNITS.MASS,
|
|
3942
|
-
prefixes: PREFIXES.NONE,
|
|
3943
|
-
value: 6479891e-11,
|
|
3944
|
-
offset: 0
|
|
3945
|
-
},
|
|
3946
|
-
dr: {
|
|
3947
|
-
name: "dr",
|
|
3948
|
-
base: BASE_UNITS.MASS,
|
|
3949
|
-
prefixes: PREFIXES.NONE,
|
|
3950
|
-
value: 0.0017718451953125,
|
|
3951
|
-
offset: 0
|
|
3952
|
-
},
|
|
3953
|
-
oz: {
|
|
3954
|
-
name: "oz",
|
|
3955
|
-
base: BASE_UNITS.MASS,
|
|
3956
|
-
prefixes: PREFIXES.NONE,
|
|
3957
|
-
value: 0.028349523125,
|
|
3958
|
-
offset: 0
|
|
3959
|
-
},
|
|
3960
|
-
lbm: {
|
|
3961
|
-
name: "lbm",
|
|
3962
|
-
base: BASE_UNITS.MASS,
|
|
3963
|
-
prefixes: PREFIXES.NONE,
|
|
3964
|
-
value: 0.45359237,
|
|
3965
|
-
offset: 0
|
|
3966
|
-
},
|
|
3967
|
-
cwt: {
|
|
3968
|
-
name: "cwt",
|
|
3969
|
-
base: BASE_UNITS.MASS,
|
|
3970
|
-
prefixes: PREFIXES.NONE,
|
|
3971
|
-
value: 45.359237,
|
|
3972
|
-
offset: 0
|
|
3973
|
-
},
|
|
3974
|
-
// Time
|
|
3975
|
-
s: {
|
|
3976
|
-
name: "s",
|
|
3977
|
-
base: BASE_UNITS.TIME,
|
|
3978
|
-
prefixes: PREFIXES.SHORT,
|
|
3979
|
-
value: 1,
|
|
3980
|
-
offset: 0
|
|
3981
|
-
},
|
|
3982
|
-
min: {
|
|
3983
|
-
name: "min",
|
|
3984
|
-
base: BASE_UNITS.TIME,
|
|
3985
|
-
prefixes: PREFIXES.NONE,
|
|
3986
|
-
value: 60,
|
|
3987
|
-
offset: 0
|
|
3988
|
-
},
|
|
3989
|
-
h: {
|
|
3990
|
-
name: "h",
|
|
3991
|
-
base: BASE_UNITS.TIME,
|
|
3992
|
-
prefixes: PREFIXES.NONE,
|
|
3993
|
-
value: 3600,
|
|
3994
|
-
offset: 0
|
|
3995
|
-
},
|
|
3996
|
-
second: {
|
|
3997
|
-
name: "second",
|
|
3998
|
-
base: BASE_UNITS.TIME,
|
|
3999
|
-
prefixes: PREFIXES.LONG,
|
|
4000
|
-
value: 1,
|
|
4001
|
-
offset: 0
|
|
4002
|
-
},
|
|
4003
|
-
sec: {
|
|
4004
|
-
name: "sec",
|
|
4005
|
-
base: BASE_UNITS.TIME,
|
|
4006
|
-
prefixes: PREFIXES.LONG,
|
|
4007
|
-
value: 1,
|
|
4008
|
-
offset: 0
|
|
4009
|
-
},
|
|
4010
|
-
minute: {
|
|
4011
|
-
name: "minute",
|
|
4012
|
-
base: BASE_UNITS.TIME,
|
|
4013
|
-
prefixes: PREFIXES.NONE,
|
|
4014
|
-
value: 60,
|
|
4015
|
-
offset: 0
|
|
4016
|
-
},
|
|
4017
|
-
hour: {
|
|
4018
|
-
name: "hour",
|
|
4019
|
-
base: BASE_UNITS.TIME,
|
|
4020
|
-
prefixes: PREFIXES.NONE,
|
|
4021
|
-
value: 3600,
|
|
4022
|
-
offset: 0
|
|
4023
|
-
},
|
|
4024
|
-
day: {
|
|
4025
|
-
name: "day",
|
|
4026
|
-
base: BASE_UNITS.TIME,
|
|
4027
|
-
prefixes: PREFIXES.NONE,
|
|
4028
|
-
value: 86400,
|
|
4029
|
-
offset: 0
|
|
4030
|
-
},
|
|
4031
|
-
week: {
|
|
4032
|
-
name: "week",
|
|
4033
|
-
base: BASE_UNITS.TIME,
|
|
4034
|
-
prefixes: PREFIXES.NONE,
|
|
4035
|
-
value: 7 * 86400,
|
|
4036
|
-
offset: 0
|
|
4037
|
-
},
|
|
4038
|
-
month: {
|
|
4039
|
-
name: "month",
|
|
4040
|
-
base: BASE_UNITS.TIME,
|
|
4041
|
-
prefixes: PREFIXES.NONE,
|
|
4042
|
-
value: 2629800,
|
|
4043
|
-
// 1/12th of Julian year
|
|
4044
|
-
offset: 0
|
|
4045
|
-
},
|
|
4046
|
-
year: {
|
|
4047
|
-
name: "year",
|
|
4048
|
-
base: BASE_UNITS.TIME,
|
|
4049
|
-
prefixes: PREFIXES.NONE,
|
|
4050
|
-
value: 31557600,
|
|
4051
|
-
// Julian year
|
|
4052
|
-
offset: 0
|
|
4053
|
-
},
|
|
4054
|
-
decade: {
|
|
4055
|
-
name: "decade",
|
|
4056
|
-
base: BASE_UNITS.TIME,
|
|
4057
|
-
prefixes: PREFIXES.NONE,
|
|
4058
|
-
value: 315576e3,
|
|
4059
|
-
// Julian decade
|
|
4060
|
-
offset: 0
|
|
4061
|
-
},
|
|
4062
|
-
century: {
|
|
4063
|
-
name: "century",
|
|
4064
|
-
base: BASE_UNITS.TIME,
|
|
4065
|
-
prefixes: PREFIXES.NONE,
|
|
4066
|
-
value: 315576e4,
|
|
4067
|
-
// Julian century
|
|
4068
|
-
offset: 0
|
|
4069
|
-
},
|
|
4070
|
-
millennium: {
|
|
4071
|
-
name: "millennium",
|
|
4072
|
-
base: BASE_UNITS.TIME,
|
|
4073
|
-
prefixes: PREFIXES.NONE,
|
|
4074
|
-
value: 315576e5,
|
|
4075
|
-
// Julian millennium
|
|
4076
|
-
offset: 0
|
|
4077
|
-
},
|
|
4078
|
-
// Frequency
|
|
4079
|
-
hertz: {
|
|
4080
|
-
name: "Hertz",
|
|
4081
|
-
base: BASE_UNITS.FREQUENCY,
|
|
4082
|
-
prefixes: PREFIXES.LONG,
|
|
4083
|
-
value: 1,
|
|
4084
|
-
offset: 0,
|
|
4085
|
-
reciprocal: true
|
|
4086
|
-
},
|
|
4087
|
-
Hz: {
|
|
4088
|
-
name: "Hz",
|
|
4089
|
-
base: BASE_UNITS.FREQUENCY,
|
|
4090
|
-
prefixes: PREFIXES.SHORT,
|
|
4091
|
-
value: 1,
|
|
4092
|
-
offset: 0,
|
|
4093
|
-
reciprocal: true
|
|
4094
|
-
},
|
|
4095
|
-
// Angle
|
|
4096
|
-
rad: {
|
|
4097
|
-
name: "rad",
|
|
4098
|
-
base: BASE_UNITS.ANGLE,
|
|
4099
|
-
prefixes: PREFIXES.SHORT,
|
|
4100
|
-
value: 1,
|
|
4101
|
-
offset: 0
|
|
4102
|
-
},
|
|
4103
|
-
radian: {
|
|
4104
|
-
name: "radian",
|
|
4105
|
-
base: BASE_UNITS.ANGLE,
|
|
4106
|
-
prefixes: PREFIXES.LONG,
|
|
4107
|
-
value: 1,
|
|
4108
|
-
offset: 0
|
|
4109
|
-
},
|
|
4110
|
-
// deg = rad / (2*pi) * 360 = rad / 0.017453292519943295769236907684888
|
|
4111
|
-
deg: {
|
|
4112
|
-
name: "deg",
|
|
4113
|
-
base: BASE_UNITS.ANGLE,
|
|
4114
|
-
prefixes: PREFIXES.SHORT,
|
|
4115
|
-
value: null,
|
|
4116
|
-
// will be filled in by calculateAngleValues()
|
|
4117
|
-
offset: 0
|
|
4118
|
-
},
|
|
4119
|
-
degree: {
|
|
4120
|
-
name: "degree",
|
|
4121
|
-
base: BASE_UNITS.ANGLE,
|
|
4122
|
-
prefixes: PREFIXES.LONG,
|
|
4123
|
-
value: null,
|
|
4124
|
-
// will be filled in by calculateAngleValues()
|
|
4125
|
-
offset: 0
|
|
4126
|
-
},
|
|
4127
|
-
// grad = rad / (2*pi) * 400 = rad / 0.015707963267948966192313216916399
|
|
4128
|
-
grad: {
|
|
4129
|
-
name: "grad",
|
|
4130
|
-
base: BASE_UNITS.ANGLE,
|
|
4131
|
-
prefixes: PREFIXES.SHORT,
|
|
4132
|
-
value: null,
|
|
4133
|
-
// will be filled in by calculateAngleValues()
|
|
4134
|
-
offset: 0
|
|
4135
|
-
},
|
|
4136
|
-
gradian: {
|
|
4137
|
-
name: "gradian",
|
|
4138
|
-
base: BASE_UNITS.ANGLE,
|
|
4139
|
-
prefixes: PREFIXES.LONG,
|
|
4140
|
-
value: null,
|
|
4141
|
-
// will be filled in by calculateAngleValues()
|
|
4142
|
-
offset: 0
|
|
4143
|
-
},
|
|
4144
|
-
// cycle = rad / (2*pi) = rad / 6.2831853071795864769252867665793
|
|
4145
|
-
cycle: {
|
|
4146
|
-
name: "cycle",
|
|
4147
|
-
base: BASE_UNITS.ANGLE,
|
|
4148
|
-
prefixes: PREFIXES.NONE,
|
|
4149
|
-
value: null,
|
|
4150
|
-
// will be filled in by calculateAngleValues()
|
|
4151
|
-
offset: 0
|
|
4152
|
-
},
|
|
4153
|
-
// arcsec = rad / (3600 * (360 / 2 * pi)) = rad / 0.0000048481368110953599358991410235795
|
|
4154
|
-
arcsec: {
|
|
4155
|
-
name: "arcsec",
|
|
4156
|
-
base: BASE_UNITS.ANGLE,
|
|
4157
|
-
prefixes: PREFIXES.NONE,
|
|
4158
|
-
value: null,
|
|
4159
|
-
// will be filled in by calculateAngleValues()
|
|
4160
|
-
offset: 0
|
|
4161
|
-
},
|
|
4162
|
-
// arcmin = rad / (60 * (360 / 2 * pi)) = rad / 0.00029088820866572159615394846141477
|
|
4163
|
-
arcmin: {
|
|
4164
|
-
name: "arcmin",
|
|
4165
|
-
base: BASE_UNITS.ANGLE,
|
|
4166
|
-
prefixes: PREFIXES.NONE,
|
|
4167
|
-
value: null,
|
|
4168
|
-
// will be filled in by calculateAngleValues()
|
|
4169
|
-
offset: 0
|
|
4170
|
-
},
|
|
4171
|
-
// Electric current
|
|
4172
|
-
A: {
|
|
4173
|
-
name: "A",
|
|
4174
|
-
base: BASE_UNITS.CURRENT,
|
|
4175
|
-
prefixes: PREFIXES.SHORT,
|
|
4176
|
-
value: 1,
|
|
4177
|
-
offset: 0
|
|
4178
|
-
},
|
|
4179
|
-
ampere: {
|
|
4180
|
-
name: "ampere",
|
|
4181
|
-
base: BASE_UNITS.CURRENT,
|
|
4182
|
-
prefixes: PREFIXES.LONG,
|
|
4183
|
-
value: 1,
|
|
4184
|
-
offset: 0
|
|
4185
|
-
},
|
|
4186
|
-
// Temperature
|
|
4187
|
-
// K(C) = °C + 273.15
|
|
4188
|
-
// K(F) = (°F + 459.67) * (5 / 9)
|
|
4189
|
-
// K(R) = °R * (5 / 9)
|
|
4190
|
-
K: {
|
|
4191
|
-
name: "K",
|
|
4192
|
-
base: BASE_UNITS.TEMPERATURE,
|
|
4193
|
-
prefixes: PREFIXES.SHORT,
|
|
4194
|
-
value: 1,
|
|
4195
|
-
offset: 0
|
|
4196
|
-
},
|
|
4197
|
-
degC: {
|
|
4198
|
-
name: "degC",
|
|
4199
|
-
base: BASE_UNITS.TEMPERATURE,
|
|
4200
|
-
prefixes: PREFIXES.SHORT,
|
|
4201
|
-
value: 1,
|
|
4202
|
-
offset: 273.15
|
|
4203
|
-
},
|
|
4204
|
-
degF: {
|
|
4205
|
-
name: "degF",
|
|
4206
|
-
base: BASE_UNITS.TEMPERATURE,
|
|
4207
|
-
prefixes: PREFIXES.SHORT,
|
|
4208
|
-
value: new Fraction2(5, 9),
|
|
4209
|
-
offset: 459.67
|
|
4210
|
-
},
|
|
4211
|
-
degR: {
|
|
4212
|
-
name: "degR",
|
|
4213
|
-
base: BASE_UNITS.TEMPERATURE,
|
|
4214
|
-
prefixes: PREFIXES.SHORT,
|
|
4215
|
-
value: new Fraction2(5, 9),
|
|
4216
|
-
offset: 0
|
|
4217
|
-
},
|
|
4218
|
-
kelvin: {
|
|
4219
|
-
name: "kelvin",
|
|
4220
|
-
base: BASE_UNITS.TEMPERATURE,
|
|
4221
|
-
prefixes: PREFIXES.LONG,
|
|
4222
|
-
value: 1,
|
|
4223
|
-
offset: 0
|
|
4224
|
-
},
|
|
4225
|
-
celsius: {
|
|
4226
|
-
name: "celsius",
|
|
4227
|
-
base: BASE_UNITS.TEMPERATURE,
|
|
4228
|
-
prefixes: PREFIXES.LONG,
|
|
4229
|
-
value: 1,
|
|
4230
|
-
offset: 273.15
|
|
4231
|
-
},
|
|
4232
|
-
fahrenheit: {
|
|
4233
|
-
name: "fahrenheit",
|
|
4234
|
-
base: BASE_UNITS.TEMPERATURE,
|
|
4235
|
-
prefixes: PREFIXES.LONG,
|
|
4236
|
-
value: new Fraction2(5, 9),
|
|
4237
|
-
offset: 459.67
|
|
4238
|
-
},
|
|
4239
|
-
rankine: {
|
|
4240
|
-
name: "rankine",
|
|
4241
|
-
base: BASE_UNITS.TEMPERATURE,
|
|
4242
|
-
prefixes: PREFIXES.LONG,
|
|
4243
|
-
value: new Fraction2(5, 9),
|
|
4244
|
-
offset: 0
|
|
4245
|
-
},
|
|
4246
|
-
// amount of substance
|
|
4247
|
-
mol: {
|
|
4248
|
-
name: "mol",
|
|
4249
|
-
base: BASE_UNITS.AMOUNT_OF_SUBSTANCE,
|
|
4250
|
-
prefixes: PREFIXES.SHORT,
|
|
4251
|
-
value: 1,
|
|
4252
|
-
offset: 0
|
|
4253
|
-
},
|
|
4254
|
-
mole: {
|
|
4255
|
-
name: "mole",
|
|
4256
|
-
base: BASE_UNITS.AMOUNT_OF_SUBSTANCE,
|
|
4257
|
-
prefixes: PREFIXES.LONG,
|
|
4258
|
-
value: 1,
|
|
4259
|
-
offset: 0
|
|
4260
|
-
},
|
|
4261
|
-
// luminous intensity
|
|
4262
|
-
cd: {
|
|
4263
|
-
name: "cd",
|
|
4264
|
-
base: BASE_UNITS.LUMINOUS_INTENSITY,
|
|
4265
|
-
prefixes: PREFIXES.SHORT,
|
|
4266
|
-
value: 1,
|
|
4267
|
-
offset: 0
|
|
4268
|
-
},
|
|
4269
|
-
candela: {
|
|
4270
|
-
name: "candela",
|
|
4271
|
-
base: BASE_UNITS.LUMINOUS_INTENSITY,
|
|
4272
|
-
prefixes: PREFIXES.LONG,
|
|
4273
|
-
value: 1,
|
|
4274
|
-
offset: 0
|
|
4275
|
-
},
|
|
4276
|
-
// Solid angle
|
|
4277
|
-
sr: {
|
|
4278
|
-
name: "sr",
|
|
4279
|
-
base: BASE_UNITS.SOLID_ANGLE,
|
|
4280
|
-
prefixes: PREFIXES.NONE,
|
|
4281
|
-
value: 1,
|
|
4282
|
-
offset: 0
|
|
4283
|
-
},
|
|
4284
|
-
steradian: {
|
|
4285
|
-
name: "steradian",
|
|
4286
|
-
base: BASE_UNITS.SOLID_ANGLE,
|
|
4287
|
-
prefixes: PREFIXES.LONG,
|
|
4288
|
-
value: 1,
|
|
4289
|
-
offset: 0
|
|
4290
|
-
},
|
|
4291
|
-
// Force
|
|
4292
|
-
N: {
|
|
4293
|
-
name: "N",
|
|
4294
|
-
base: BASE_UNITS.FORCE,
|
|
4295
|
-
prefixes: PREFIXES.SHORT,
|
|
4296
|
-
value: 1,
|
|
4297
|
-
offset: 0
|
|
4298
|
-
},
|
|
4299
|
-
newton: {
|
|
4300
|
-
name: "newton",
|
|
4301
|
-
base: BASE_UNITS.FORCE,
|
|
4302
|
-
prefixes: PREFIXES.LONG,
|
|
4303
|
-
value: 1,
|
|
4304
|
-
offset: 0
|
|
4305
|
-
},
|
|
4306
|
-
dyn: {
|
|
4307
|
-
name: "dyn",
|
|
4308
|
-
base: BASE_UNITS.FORCE,
|
|
4309
|
-
prefixes: PREFIXES.SHORT,
|
|
4310
|
-
value: 1e-5,
|
|
4311
|
-
offset: 0
|
|
4312
|
-
},
|
|
4313
|
-
dyne: {
|
|
4314
|
-
name: "dyne",
|
|
4315
|
-
base: BASE_UNITS.FORCE,
|
|
4316
|
-
prefixes: PREFIXES.LONG,
|
|
4317
|
-
value: 1e-5,
|
|
4318
|
-
offset: 0
|
|
4319
|
-
},
|
|
4320
|
-
lbf: {
|
|
4321
|
-
name: "lbf",
|
|
4322
|
-
base: BASE_UNITS.FORCE,
|
|
4323
|
-
prefixes: PREFIXES.NONE,
|
|
4324
|
-
value: 4.4482216152605,
|
|
4325
|
-
offset: 0
|
|
4326
|
-
},
|
|
4327
|
-
poundforce: {
|
|
4328
|
-
name: "poundforce",
|
|
4329
|
-
base: BASE_UNITS.FORCE,
|
|
4330
|
-
prefixes: PREFIXES.NONE,
|
|
4331
|
-
value: 4.4482216152605,
|
|
4332
|
-
offset: 0
|
|
4333
|
-
},
|
|
4334
|
-
kip: {
|
|
4335
|
-
name: "kip",
|
|
4336
|
-
base: BASE_UNITS.FORCE,
|
|
4337
|
-
prefixes: PREFIXES.LONG,
|
|
4338
|
-
value: 4448.2216,
|
|
4339
|
-
offset: 0
|
|
4340
|
-
},
|
|
4341
|
-
kilogramforce: {
|
|
4342
|
-
name: "kilogramforce",
|
|
4343
|
-
base: BASE_UNITS.FORCE,
|
|
4344
|
-
prefixes: PREFIXES.NONE,
|
|
4345
|
-
value: 9.80665,
|
|
4346
|
-
offset: 0
|
|
4347
|
-
},
|
|
4348
|
-
// Energy
|
|
4349
|
-
J: {
|
|
4350
|
-
name: "J",
|
|
4351
|
-
base: BASE_UNITS.ENERGY,
|
|
4352
|
-
prefixes: PREFIXES.SHORT,
|
|
4353
|
-
value: 1,
|
|
4354
|
-
offset: 0
|
|
4355
|
-
},
|
|
4356
|
-
joule: {
|
|
4357
|
-
name: "joule",
|
|
4358
|
-
base: BASE_UNITS.ENERGY,
|
|
4359
|
-
prefixes: PREFIXES.LONG,
|
|
4360
|
-
value: 1,
|
|
4361
|
-
offset: 0
|
|
4362
|
-
},
|
|
4363
|
-
erg: {
|
|
4364
|
-
name: "erg",
|
|
4365
|
-
base: BASE_UNITS.ENERGY,
|
|
4366
|
-
prefixes: PREFIXES.SHORTLONG,
|
|
4367
|
-
// Both kiloerg and kerg are acceptable
|
|
4368
|
-
value: 1e-7,
|
|
4369
|
-
offset: 0
|
|
4370
|
-
},
|
|
4371
|
-
Wh: {
|
|
4372
|
-
name: "Wh",
|
|
4373
|
-
base: BASE_UNITS.ENERGY,
|
|
4374
|
-
prefixes: PREFIXES.SHORT,
|
|
4375
|
-
value: 3600,
|
|
4376
|
-
offset: 0
|
|
4377
|
-
},
|
|
4378
|
-
BTU: {
|
|
4379
|
-
name: "BTU",
|
|
4380
|
-
base: BASE_UNITS.ENERGY,
|
|
4381
|
-
prefixes: PREFIXES.BTU,
|
|
4382
|
-
value: 1055.05585262,
|
|
4383
|
-
offset: 0
|
|
4384
|
-
},
|
|
4385
|
-
eV: {
|
|
4386
|
-
name: "eV",
|
|
4387
|
-
base: BASE_UNITS.ENERGY,
|
|
4388
|
-
prefixes: PREFIXES.SHORT,
|
|
4389
|
-
value: 1602176634e-28,
|
|
4390
|
-
offset: 0
|
|
4391
|
-
},
|
|
4392
|
-
electronvolt: {
|
|
4393
|
-
name: "electronvolt",
|
|
4394
|
-
base: BASE_UNITS.ENERGY,
|
|
4395
|
-
prefixes: PREFIXES.LONG,
|
|
4396
|
-
value: 1602176634e-28,
|
|
4397
|
-
offset: 0
|
|
4398
|
-
},
|
|
4399
|
-
// Power
|
|
4400
|
-
W: {
|
|
4401
|
-
name: "W",
|
|
4402
|
-
base: BASE_UNITS.POWER,
|
|
4403
|
-
prefixes: PREFIXES.SHORT,
|
|
4404
|
-
value: 1,
|
|
4405
|
-
offset: 0
|
|
4406
|
-
},
|
|
4407
|
-
watt: {
|
|
4408
|
-
name: "watt",
|
|
4409
|
-
base: BASE_UNITS.POWER,
|
|
4410
|
-
prefixes: PREFIXES.LONG,
|
|
4411
|
-
value: 1,
|
|
4412
|
-
offset: 0
|
|
4413
|
-
},
|
|
4414
|
-
hp: {
|
|
4415
|
-
name: "hp",
|
|
4416
|
-
base: BASE_UNITS.POWER,
|
|
4417
|
-
prefixes: PREFIXES.NONE,
|
|
4418
|
-
value: 745.6998715386,
|
|
4419
|
-
offset: 0
|
|
4420
|
-
},
|
|
4421
|
-
// Electrical power units
|
|
4422
|
-
VAR: {
|
|
4423
|
-
name: "VAR",
|
|
4424
|
-
base: BASE_UNITS.POWER,
|
|
4425
|
-
prefixes: PREFIXES.SHORT,
|
|
4426
|
-
value: Complex2.I,
|
|
4427
|
-
offset: 0
|
|
4428
|
-
},
|
|
4429
|
-
VA: {
|
|
4430
|
-
name: "VA",
|
|
4431
|
-
base: BASE_UNITS.POWER,
|
|
4432
|
-
prefixes: PREFIXES.SHORT,
|
|
4433
|
-
value: 1,
|
|
4434
|
-
offset: 0
|
|
4435
|
-
},
|
|
4436
|
-
// Pressure
|
|
4437
|
-
Pa: {
|
|
4438
|
-
name: "Pa",
|
|
4439
|
-
base: BASE_UNITS.PRESSURE,
|
|
4440
|
-
prefixes: PREFIXES.SHORT,
|
|
4441
|
-
value: 1,
|
|
4442
|
-
offset: 0
|
|
4443
|
-
},
|
|
4444
|
-
psi: {
|
|
4445
|
-
name: "psi",
|
|
4446
|
-
base: BASE_UNITS.PRESSURE,
|
|
4447
|
-
prefixes: PREFIXES.NONE,
|
|
4448
|
-
value: 6894.75729276459,
|
|
4449
|
-
offset: 0
|
|
4450
|
-
},
|
|
4451
|
-
atm: {
|
|
4452
|
-
name: "atm",
|
|
4453
|
-
base: BASE_UNITS.PRESSURE,
|
|
4454
|
-
prefixes: PREFIXES.NONE,
|
|
4455
|
-
value: 101325,
|
|
4456
|
-
offset: 0
|
|
4457
|
-
},
|
|
4458
|
-
bar: {
|
|
4459
|
-
name: "bar",
|
|
4460
|
-
base: BASE_UNITS.PRESSURE,
|
|
4461
|
-
prefixes: PREFIXES.SHORTLONG,
|
|
4462
|
-
value: 1e5,
|
|
4463
|
-
offset: 0
|
|
4464
|
-
},
|
|
4465
|
-
torr: {
|
|
4466
|
-
name: "torr",
|
|
4467
|
-
base: BASE_UNITS.PRESSURE,
|
|
4468
|
-
prefixes: PREFIXES.NONE,
|
|
4469
|
-
value: 133.322,
|
|
4470
|
-
offset: 0
|
|
4471
|
-
},
|
|
4472
|
-
mmHg: {
|
|
4473
|
-
name: "mmHg",
|
|
4474
|
-
base: BASE_UNITS.PRESSURE,
|
|
4475
|
-
prefixes: PREFIXES.NONE,
|
|
4476
|
-
value: 133.322,
|
|
4477
|
-
offset: 0
|
|
4478
|
-
},
|
|
4479
|
-
mmH2O: {
|
|
4480
|
-
name: "mmH2O",
|
|
4481
|
-
base: BASE_UNITS.PRESSURE,
|
|
4482
|
-
prefixes: PREFIXES.NONE,
|
|
4483
|
-
value: 9.80665,
|
|
4484
|
-
offset: 0
|
|
4485
|
-
},
|
|
4486
|
-
cmH2O: {
|
|
4487
|
-
name: "cmH2O",
|
|
4488
|
-
base: BASE_UNITS.PRESSURE,
|
|
4489
|
-
prefixes: PREFIXES.NONE,
|
|
4490
|
-
value: 98.0665,
|
|
4491
|
-
offset: 0
|
|
4492
|
-
},
|
|
4493
|
-
// Electric charge
|
|
4494
|
-
coulomb: {
|
|
4495
|
-
name: "coulomb",
|
|
4496
|
-
base: BASE_UNITS.ELECTRIC_CHARGE,
|
|
4497
|
-
prefixes: PREFIXES.LONG,
|
|
4498
|
-
value: 1,
|
|
4499
|
-
offset: 0
|
|
4500
|
-
},
|
|
4501
|
-
C: {
|
|
4502
|
-
name: "C",
|
|
4503
|
-
base: BASE_UNITS.ELECTRIC_CHARGE,
|
|
4504
|
-
prefixes: PREFIXES.SHORT,
|
|
4505
|
-
value: 1,
|
|
4506
|
-
offset: 0
|
|
4507
|
-
},
|
|
4508
|
-
// Electric capacitance
|
|
4509
|
-
farad: {
|
|
4510
|
-
name: "farad",
|
|
4511
|
-
base: BASE_UNITS.ELECTRIC_CAPACITANCE,
|
|
4512
|
-
prefixes: PREFIXES.LONG,
|
|
4513
|
-
value: 1,
|
|
4514
|
-
offset: 0
|
|
4515
|
-
},
|
|
4516
|
-
F: {
|
|
4517
|
-
name: "F",
|
|
4518
|
-
base: BASE_UNITS.ELECTRIC_CAPACITANCE,
|
|
4519
|
-
prefixes: PREFIXES.SHORT,
|
|
4520
|
-
value: 1,
|
|
4521
|
-
offset: 0
|
|
4522
|
-
},
|
|
4523
|
-
// Electric potential
|
|
4524
|
-
volt: {
|
|
4525
|
-
name: "volt",
|
|
4526
|
-
base: BASE_UNITS.ELECTRIC_POTENTIAL,
|
|
4527
|
-
prefixes: PREFIXES.LONG,
|
|
4528
|
-
value: 1,
|
|
4529
|
-
offset: 0
|
|
4530
|
-
},
|
|
4531
|
-
V: {
|
|
4532
|
-
name: "V",
|
|
4533
|
-
base: BASE_UNITS.ELECTRIC_POTENTIAL,
|
|
4534
|
-
prefixes: PREFIXES.SHORT,
|
|
4535
|
-
value: 1,
|
|
4536
|
-
offset: 0
|
|
4537
|
-
},
|
|
4538
|
-
// Electric resistance
|
|
4539
|
-
ohm: {
|
|
4540
|
-
name: "ohm",
|
|
4541
|
-
base: BASE_UNITS.ELECTRIC_RESISTANCE,
|
|
4542
|
-
prefixes: PREFIXES.SHORTLONG,
|
|
4543
|
-
// Both Mohm and megaohm are acceptable
|
|
4544
|
-
value: 1,
|
|
4545
|
-
offset: 0
|
|
4546
|
-
},
|
|
4547
|
-
/*
|
|
4548
|
-
* Unicode breaks in browsers if charset is not specified
|
|
4549
|
-
Ω: {
|
|
4550
|
-
name: 'Ω',
|
|
4551
|
-
base: BASE_UNITS.ELECTRIC_RESISTANCE,
|
|
4552
|
-
prefixes: PREFIXES.SHORT,
|
|
4553
|
-
value: 1,
|
|
4554
|
-
offset: 0
|
|
4555
|
-
},
|
|
4556
|
-
*/
|
|
4557
|
-
// Electric inductance
|
|
4558
|
-
henry: {
|
|
4559
|
-
name: "henry",
|
|
4560
|
-
base: BASE_UNITS.ELECTRIC_INDUCTANCE,
|
|
4561
|
-
prefixes: PREFIXES.LONG,
|
|
4562
|
-
value: 1,
|
|
4563
|
-
offset: 0
|
|
4564
|
-
},
|
|
4565
|
-
H: {
|
|
4566
|
-
name: "H",
|
|
4567
|
-
base: BASE_UNITS.ELECTRIC_INDUCTANCE,
|
|
4568
|
-
prefixes: PREFIXES.SHORT,
|
|
4569
|
-
value: 1,
|
|
4570
|
-
offset: 0
|
|
4571
|
-
},
|
|
4572
|
-
// Electric conductance
|
|
4573
|
-
siemens: {
|
|
4574
|
-
name: "siemens",
|
|
4575
|
-
base: BASE_UNITS.ELECTRIC_CONDUCTANCE,
|
|
4576
|
-
prefixes: PREFIXES.LONG,
|
|
4577
|
-
value: 1,
|
|
4578
|
-
offset: 0
|
|
4579
|
-
},
|
|
4580
|
-
S: {
|
|
4581
|
-
name: "S",
|
|
4582
|
-
base: BASE_UNITS.ELECTRIC_CONDUCTANCE,
|
|
4583
|
-
prefixes: PREFIXES.SHORT,
|
|
4584
|
-
value: 1,
|
|
4585
|
-
offset: 0
|
|
4586
|
-
},
|
|
4587
|
-
// Magnetic flux
|
|
4588
|
-
weber: {
|
|
4589
|
-
name: "weber",
|
|
4590
|
-
base: BASE_UNITS.MAGNETIC_FLUX,
|
|
4591
|
-
prefixes: PREFIXES.LONG,
|
|
4592
|
-
value: 1,
|
|
4593
|
-
offset: 0
|
|
4594
|
-
},
|
|
4595
|
-
Wb: {
|
|
4596
|
-
name: "Wb",
|
|
4597
|
-
base: BASE_UNITS.MAGNETIC_FLUX,
|
|
4598
|
-
prefixes: PREFIXES.SHORT,
|
|
4599
|
-
value: 1,
|
|
4600
|
-
offset: 0
|
|
4601
|
-
},
|
|
4602
|
-
// Magnetic flux density
|
|
4603
|
-
tesla: {
|
|
4604
|
-
name: "tesla",
|
|
4605
|
-
base: BASE_UNITS.MAGNETIC_FLUX_DENSITY,
|
|
4606
|
-
prefixes: PREFIXES.LONG,
|
|
4607
|
-
value: 1,
|
|
4608
|
-
offset: 0
|
|
4609
|
-
},
|
|
4610
|
-
T: {
|
|
4611
|
-
name: "T",
|
|
4612
|
-
base: BASE_UNITS.MAGNETIC_FLUX_DENSITY,
|
|
4613
|
-
prefixes: PREFIXES.SHORT,
|
|
4614
|
-
value: 1,
|
|
4615
|
-
offset: 0
|
|
4616
|
-
},
|
|
4617
|
-
// Binary
|
|
4618
|
-
b: {
|
|
4619
|
-
name: "b",
|
|
4620
|
-
base: BASE_UNITS.BIT,
|
|
4621
|
-
prefixes: PREFIXES.BINARY_SHORT,
|
|
4622
|
-
value: 1,
|
|
4623
|
-
offset: 0
|
|
4624
|
-
},
|
|
4625
|
-
bits: {
|
|
4626
|
-
name: "bits",
|
|
4627
|
-
base: BASE_UNITS.BIT,
|
|
4628
|
-
prefixes: PREFIXES.BINARY_LONG,
|
|
4629
|
-
value: 1,
|
|
4630
|
-
offset: 0
|
|
4631
|
-
},
|
|
4632
|
-
B: {
|
|
4633
|
-
name: "B",
|
|
4634
|
-
base: BASE_UNITS.BIT,
|
|
4635
|
-
prefixes: PREFIXES.BINARY_SHORT,
|
|
4636
|
-
value: 8,
|
|
4637
|
-
offset: 0
|
|
4638
|
-
},
|
|
4639
|
-
bytes: {
|
|
4640
|
-
name: "bytes",
|
|
4641
|
-
base: BASE_UNITS.BIT,
|
|
4642
|
-
prefixes: PREFIXES.BINARY_LONG,
|
|
4643
|
-
value: 8,
|
|
4644
|
-
offset: 0
|
|
4645
|
-
}
|
|
4646
|
-
};
|
|
4647
|
-
const ALIASES = {
|
|
4648
|
-
meters: "meter",
|
|
4649
|
-
// Astronomical / nautical / typography aliases (B-5 port). Lowercase
|
|
4650
|
-
// 'au' is deliberately ABSENT: it collides with the atomic unit of
|
|
4651
|
-
// length (Bohr radius, ~5.29e-11 m), 21 orders of magnitude smaller.
|
|
4652
|
-
AU: "astronomicalUnit",
|
|
4653
|
-
astronomicalUnits: "astronomicalUnit",
|
|
4654
|
-
lightyears: "lightyear",
|
|
4655
|
-
parsecs: "parsec",
|
|
4656
|
-
nmi: "nauticalMile",
|
|
4657
|
-
nauticalMiles: "nauticalMile",
|
|
4658
|
-
fathoms: "fathom",
|
|
4659
|
-
furlongs: "furlong",
|
|
4660
|
-
points: "point",
|
|
4661
|
-
picas: "pica",
|
|
4662
|
-
inches: "inch",
|
|
4663
|
-
feet: "foot",
|
|
4664
|
-
yards: "yard",
|
|
4665
|
-
miles: "mile",
|
|
4666
|
-
links: "link",
|
|
4667
|
-
rods: "rod",
|
|
4668
|
-
chains: "chain",
|
|
4669
|
-
angstroms: "angstrom",
|
|
4670
|
-
lt: "l",
|
|
4671
|
-
litres: "litre",
|
|
4672
|
-
liter: "litre",
|
|
4673
|
-
liters: "litre",
|
|
4674
|
-
teaspoons: "teaspoon",
|
|
4675
|
-
tablespoons: "tablespoon",
|
|
4676
|
-
minims: "minim",
|
|
4677
|
-
fldr: "fluiddram",
|
|
4678
|
-
fluiddrams: "fluiddram",
|
|
4679
|
-
floz: "fluidounce",
|
|
4680
|
-
fluidounces: "fluidounce",
|
|
4681
|
-
gi: "gill",
|
|
4682
|
-
gills: "gill",
|
|
4683
|
-
cp: "cup",
|
|
4684
|
-
cups: "cup",
|
|
4685
|
-
pt: "pint",
|
|
4686
|
-
pints: "pint",
|
|
4687
|
-
qt: "quart",
|
|
4688
|
-
quarts: "quart",
|
|
4689
|
-
gal: "gallon",
|
|
4690
|
-
gallons: "gallon",
|
|
4691
|
-
bbl: "beerbarrel",
|
|
4692
|
-
beerbarrels: "beerbarrel",
|
|
4693
|
-
obl: "oilbarrel",
|
|
4694
|
-
oilbarrels: "oilbarrel",
|
|
4695
|
-
hogsheads: "hogshead",
|
|
4696
|
-
gtts: "gtt",
|
|
4697
|
-
grams: "gram",
|
|
4698
|
-
tons: "ton",
|
|
4699
|
-
tonnes: "tonne",
|
|
4700
|
-
grains: "grain",
|
|
4701
|
-
drams: "dram",
|
|
4702
|
-
ounces: "ounce",
|
|
4703
|
-
poundmasses: "poundmass",
|
|
4704
|
-
hundredweights: "hundredweight",
|
|
4705
|
-
sticks: "stick",
|
|
4706
|
-
lb: "lbm",
|
|
4707
|
-
lbs: "lbm",
|
|
4708
|
-
kips: "kip",
|
|
4709
|
-
kgf: "kilogramforce",
|
|
4710
|
-
acres: "acre",
|
|
4711
|
-
hectares: "hectare",
|
|
4712
|
-
sqfeet: "sqft",
|
|
4713
|
-
sqyard: "sqyd",
|
|
4714
|
-
sqmile: "sqmi",
|
|
4715
|
-
sqmiles: "sqmi",
|
|
4716
|
-
mmhg: "mmHg",
|
|
4717
|
-
mmh2o: "mmH2O",
|
|
4718
|
-
cmh2o: "cmH2O",
|
|
4719
|
-
seconds: "second",
|
|
4720
|
-
secs: "second",
|
|
4721
|
-
minutes: "minute",
|
|
4722
|
-
mins: "minute",
|
|
4723
|
-
hours: "hour",
|
|
4724
|
-
hr: "hour",
|
|
4725
|
-
hrs: "hour",
|
|
4726
|
-
days: "day",
|
|
4727
|
-
weeks: "week",
|
|
4728
|
-
months: "month",
|
|
4729
|
-
years: "year",
|
|
4730
|
-
decades: "decade",
|
|
4731
|
-
centuries: "century",
|
|
4732
|
-
millennia: "millennium",
|
|
4733
|
-
hertz: "hertz",
|
|
4734
|
-
radians: "radian",
|
|
4735
|
-
degrees: "degree",
|
|
4736
|
-
gradians: "gradian",
|
|
4737
|
-
cycles: "cycle",
|
|
4738
|
-
arcsecond: "arcsec",
|
|
4739
|
-
arcseconds: "arcsec",
|
|
4740
|
-
arcminute: "arcmin",
|
|
4741
|
-
arcminutes: "arcmin",
|
|
4742
|
-
BTUs: "BTU",
|
|
4743
|
-
watts: "watt",
|
|
4744
|
-
joules: "joule",
|
|
4745
|
-
amperes: "ampere",
|
|
4746
|
-
amps: "ampere",
|
|
4747
|
-
amp: "ampere",
|
|
4748
|
-
coulombs: "coulomb",
|
|
4749
|
-
volts: "volt",
|
|
4750
|
-
ohms: "ohm",
|
|
4751
|
-
farads: "farad",
|
|
4752
|
-
webers: "weber",
|
|
4753
|
-
teslas: "tesla",
|
|
4754
|
-
electronvolts: "electronvolt",
|
|
4755
|
-
moles: "mole",
|
|
4756
|
-
bit: "bits",
|
|
4757
|
-
byte: "bytes"
|
|
4758
|
-
};
|
|
4235
|
+
function imaginaryValue(scale) {
|
|
4236
|
+
const i = Complex2.I;
|
|
4237
|
+
return scale === 1 || i === void 0 ? i : multiplyScalar2(i, scale);
|
|
4238
|
+
}
|
|
4239
|
+
const UNITS = {};
|
|
4240
|
+
for (const key of Object.keys(UNIT_ROWS)) {
|
|
4241
|
+
const row = UNIT_ROWS[key];
|
|
4242
|
+
const exact = readUnitScale(row.scale);
|
|
4243
|
+
const scaled = roundExactScale(exact);
|
|
4244
|
+
const exactOffset = row.offset === void 0 ? UNIT_ZERO_SCALE : readUnitScale(row.offset);
|
|
4245
|
+
const def = {
|
|
4246
|
+
name: row.name ?? key,
|
|
4247
|
+
base: BASE_UNITS[row.base],
|
|
4248
|
+
prefixes: PREFIXES[row.prefixes],
|
|
4249
|
+
value: row.imaginary ? imaginaryValue(scaled) : scaled,
|
|
4250
|
+
offset: roundExactScale(exactOffset)
|
|
4251
|
+
};
|
|
4252
|
+
if (row.reciprocal) def.reciprocal = true;
|
|
4253
|
+
if (!row.imaginary) attachExactScale(def, exact, exactOffset);
|
|
4254
|
+
UNITS[key] = def;
|
|
4255
|
+
}
|
|
4759
4256
|
function calculateAngleValues(config3) {
|
|
4760
|
-
|
|
4761
|
-
|
|
4762
|
-
|
|
4763
|
-
|
|
4764
|
-
UNITS.
|
|
4765
|
-
UNITS.cycle.value = pi.times(2);
|
|
4766
|
-
UNITS.arcsec.value = pi.div(648e3);
|
|
4767
|
-
UNITS.arcmin.value = pi.div(10800);
|
|
4768
|
-
} else {
|
|
4769
|
-
UNITS.rad.value = 1;
|
|
4770
|
-
UNITS.deg.value = Math.PI / 180;
|
|
4771
|
-
UNITS.grad.value = Math.PI / 200;
|
|
4772
|
-
UNITS.cycle.value = Math.PI * 2;
|
|
4773
|
-
UNITS.arcsec.value = Math.PI / 648e3;
|
|
4774
|
-
UNITS.arcmin.value = Math.PI / 10800;
|
|
4257
|
+
for (const key in UNITS) {
|
|
4258
|
+
if (!hasOwnProperty(UNITS, key)) continue;
|
|
4259
|
+
const exact = UNITS[key].exact;
|
|
4260
|
+
if (exact === void 0 || irrationalPower(exact, "pi") === 0) continue;
|
|
4261
|
+
UNITS[key].value = (config3.number === "BigNumber" ? exactToBigNumber(exact) : void 0) ?? roundExactScale(exact);
|
|
4775
4262
|
}
|
|
4776
|
-
UNITS.radian.value = UNITS.rad.value;
|
|
4777
|
-
UNITS.degree.value = UNITS.deg.value;
|
|
4778
|
-
UNITS.gradian.value = UNITS.grad.value;
|
|
4779
4263
|
}
|
|
4780
|
-
calculateAngleValues(config2);
|
|
4781
4264
|
if (on) {
|
|
4782
4265
|
on("config", function(curr, prev) {
|
|
4783
4266
|
if (curr.number !== prev.number) {
|
|
@@ -4891,9 +4374,9 @@ var createUnitClass = /* @__PURE__ */ factory(
|
|
|
4891
4374
|
unit.dimensions = unit.base.dimensions;
|
|
4892
4375
|
}
|
|
4893
4376
|
}
|
|
4894
|
-
for (const name2 in
|
|
4895
|
-
if (hasOwnProperty(
|
|
4896
|
-
const unit = UNITS[
|
|
4377
|
+
for (const name2 in UNIT_ROW_ALIASES) {
|
|
4378
|
+
if (hasOwnProperty(UNIT_ROW_ALIASES, name2)) {
|
|
4379
|
+
const unit = UNITS[UNIT_ROW_ALIASES[name2]];
|
|
4897
4380
|
const alias = {};
|
|
4898
4381
|
const aliasRec = alias;
|
|
4899
4382
|
const unitRec = unit;
|
|
@@ -4903,9 +4386,11 @@ var createUnitClass = /* @__PURE__ */ factory(
|
|
|
4903
4386
|
}
|
|
4904
4387
|
}
|
|
4905
4388
|
alias.name = name2;
|
|
4389
|
+
if (unit.exact !== void 0) attachExactScale(alias, unit.exact, unit.exactOffset);
|
|
4906
4390
|
UNITS[name2] = alias;
|
|
4907
4391
|
}
|
|
4908
4392
|
}
|
|
4393
|
+
calculateAngleValues(config2);
|
|
4909
4394
|
Unit2.isValidAlpha = function isValidAlpha(c2) {
|
|
4910
4395
|
return /^[a-zA-Z]$/.test(c2);
|
|
4911
4396
|
};
|
|
@@ -5727,7 +5212,7 @@ var COMPLEX_NEG_ONE = new Complex(-1, 0);
|
|
|
5727
5212
|
function isFraction2(value) {
|
|
5728
5213
|
return value instanceof Fraction;
|
|
5729
5214
|
}
|
|
5730
|
-
function
|
|
5215
|
+
function gcd2(a, b) {
|
|
5731
5216
|
a = a < 0n ? -a : a;
|
|
5732
5217
|
b = b < 0n ? -b : b;
|
|
5733
5218
|
while (b !== 0n) {
|
|
@@ -5746,7 +5231,7 @@ function reducePair(num, den) {
|
|
|
5746
5231
|
den = -den;
|
|
5747
5232
|
}
|
|
5748
5233
|
if (num === 0n) return [0n, 1n];
|
|
5749
|
-
const g =
|
|
5234
|
+
const g = gcd2(num, den);
|
|
5750
5235
|
return [num / g, den / g];
|
|
5751
5236
|
}
|
|
5752
5237
|
var Fraction = class _Fraction {
|
|
@@ -5801,7 +5286,7 @@ var Fraction = class _Fraction {
|
|
|
5801
5286
|
num = -num;
|
|
5802
5287
|
den = -den;
|
|
5803
5288
|
}
|
|
5804
|
-
const g =
|
|
5289
|
+
const g = gcd2(num, den);
|
|
5805
5290
|
this.numerator = num / g;
|
|
5806
5291
|
this.denominator = den / g;
|
|
5807
5292
|
}
|
|
@@ -6537,6 +6022,39 @@ export {
|
|
|
6537
6022
|
BIGNUMBER_LN10,
|
|
6538
6023
|
UnitParseError,
|
|
6539
6024
|
DimensionMismatchError,
|
|
6025
|
+
NAMED_IRRATIONALS,
|
|
6026
|
+
irrationalPower,
|
|
6027
|
+
isRationalScale,
|
|
6028
|
+
UNIT_EXACT_SCALE,
|
|
6029
|
+
namedIrrationalScale,
|
|
6030
|
+
PI_EXACT_SCALE,
|
|
6031
|
+
LN2_EXACT_SCALE,
|
|
6032
|
+
decimalExactScale,
|
|
6033
|
+
exactScaleOf,
|
|
6034
|
+
binaryExactScale,
|
|
6035
|
+
ratioExactScale,
|
|
6036
|
+
multiplyExactScales,
|
|
6037
|
+
divideExactScales,
|
|
6038
|
+
powerExactScale,
|
|
6039
|
+
exactScalesEqual,
|
|
6040
|
+
addExactScales,
|
|
6041
|
+
clearExactScaleNumberCache,
|
|
6042
|
+
exactScaleNumberCacheSize,
|
|
6043
|
+
exactScaleToNumber,
|
|
6044
|
+
formatExactScale,
|
|
6045
|
+
readScaleExpression,
|
|
6046
|
+
UNIT_PREFIX_SETS,
|
|
6047
|
+
unitPrefixExactScale,
|
|
6048
|
+
getUnitPrefix,
|
|
6049
|
+
NAMED_SCALES,
|
|
6050
|
+
UNIT_ROWS,
|
|
6051
|
+
UNIT_ROW_ALIASES,
|
|
6052
|
+
namedExactScale,
|
|
6053
|
+
readUnitScale,
|
|
6054
|
+
getUnitRow,
|
|
6055
|
+
unitRowExactScale,
|
|
6056
|
+
unitRowValue,
|
|
6057
|
+
unitRowExactOffset,
|
|
6540
6058
|
createUnitClass,
|
|
6541
6059
|
isComplex2,
|
|
6542
6060
|
Complex,
|