* 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)
| 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 | */ |
| 31 | function 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); |