MCPcopy Create free account
hub / github.com/cortex-js/compute-engine / boxMachineNumber

Function boxMachineNumber

src/compute-engine/boxed-expression/apply.ts:27–35  ·  view source on GitHub ↗

* Box a kernel result that is a plain JS double. * * In an engine working above machine precision, a plain-double result means * it was computed at machine precision (either no bignum kernel exists for * the operator, or the bignum kernel signalled "out of domain" and the * machine lane answere

(ce: IComputeEngine, value: number)

Source from the content-addressed store, hash-verified

25 * downstream arithmetic to machine precision, mirroring float contagion.
26 *
27 * Small integers stay exact: machine kernels return them for exact special
28 * values (e.g. `BesselI(0, 0)` = 1), and `ce.number()` interns them.
29 * Non-finite values keep their canonical boxing (±oo, NaN).
30 */
31function boxMachineNumber(ce: IComputeEngine, value: number): Expression {
32 if (
33 bignumPreferred(ce) &&
34 Number.isFinite(value) &&
35 !(Number.isInteger(value) && Math.abs(value) <= SMALL_INTEGER)
36 )
37 return ce.number(new MachineNumericValue(value));
38 return ce.number(value);

Callers 3

applyFunction · 0.85
applyNFunction · 0.85
apply2Function · 0.85

Calls 5

bignumPreferredFunction · 0.90
absMethod · 0.65
numberMethod · 0.65
isFiniteMethod · 0.45
isIntegerMethod · 0.45

Tested by

no test coverage detected