UNPKG

lakutata

Version:

An IoC-based universal application framework.

107 lines (101 loc) 2.28 kB
/* Build Date: Mon Jan 05 2026 23:52:23 GMT+0800 (China Standard Time) */ "use strict"; Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" }); function t(t, e, o, l, i) { let s; let n; const a = i * 8 - l - 1; const h = (1 << a) - 1; const f = h >> 1; let r = -7; let w = o ? i - 1 : 0; const M = o ? -1 : 1; let c = t[e + w]; w += M; s = c & (1 << -r) - 1; c >>= -r; r += a; while (r > 0) { s = s * 256 + t[e + w]; w += M; r -= 8; } n = s & (1 << -r) - 1; s >>= -r; r += l; while (r > 0) { n = n * 256 + t[e + w]; w += M; r -= 8; } if (s === 0) { s = 1 - f; } else if (s === h) { return n ? NaN : (c ? -1 : 1) * Infinity; } else { n = n + Math.pow(2, l); s = s - f; } return (c ? -1 : 1) * n * Math.pow(2, s - l); } function e(t, e, o, l, i, s) { let n; let a; let h; let f = s * 8 - i - 1; const r = (1 << f) - 1; const w = r >> 1; const M = i === 23 ? Math.pow(2, -24) - Math.pow(2, -77) : 0; let c = l ? 0 : s - 1; const p = l ? 1 : -1; const u = e < 0 || e === 0 && 1 / e < 0 ? 1 : 0; e = Math.abs(e); if (isNaN(e) || e === Infinity) { a = isNaN(e) ? 1 : 0; n = r; } else { n = Math.floor(Math.log(e) / Math.LN2); if (e * (h = Math.pow(2, -n)) < 1) { n--; h *= 2; } if (n + w >= 1) { e += M / h; } else { e += M * Math.pow(2, 1 - w); } if (e * h >= 2) { n++; h /= 2; } if (n + w >= r) { a = 0; n = r; } else if (n + w >= 1) { a = (e * h - 1) * Math.pow(2, i); n = n + w; } else { a = e * Math.pow(2, w - 1) * Math.pow(2, i); n = 0; } } while (i >= 8) { t[o + c] = a & 255; c += p; a /= 256; i -= 8; } n = n << i | a; f += i; while (f > 0) { t[o + c] = n & 255; c += p; n /= 256; f -= 8; } t[o + c - p] |= u * 128; } exports.readIEEE754 = t; exports.writeIEEE754 = e;