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

Function toInteger

src/compute-engine/boxed-expression/numerics.ts:186–194  ·  view source on GitHub ↗
(expr: Expression | undefined)

Source from the content-addressed store, hash-verified

184 * instead. (This is what makes `toInteger` unsuitable for value-semantic uses
185 * such as primality testing — see `isPrime` in predicates.ts.)
186 */
187export function toInteger(expr: Expression | undefined): number | null {
188 if (!isNumber(expr)) return null;
189 const num = expr.numericValue;
190 const re = typeof num === 'number' ? num : num.re;
191 if (!Number.isFinite(re)) return null;
192 const n = Math.round(re);
193 if (!Number.isSafeInteger(n)) return null;
194 return n;
195}
196
197/**

Callers 10

collections.tsFile · 0.90
takeIteratorFunction · 0.90
takeCountFunction · 0.90
core.tsFile · 0.90
combinatorics.tsFile · 0.90
computeBinningFunction · 0.90
statistics.tsFile · 0.90
parseFitArgsFunction · 0.90
arithmetic.tsFile · 0.90

Calls 3

isNumberFunction · 0.90
isFiniteMethod · 0.45
roundMethod · 0.45

Tested by

no test coverage detected