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

Function asBignum

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

Source from the content-addressed store, hash-verified

115 return bigintValue(x as MathJsonExpression);
116}
117
118export function asBignum(expr: Expression | undefined): BigDecimal | null {
119 if (expr === undefined || expr === null) return null;
120 if (!isNumber(expr)) return null;
121 const num = typeof expr === 'number' ? expr : expr.numericValue;
122
123 if (typeof num === 'number') return expr.engine.bignum(num);
124
125 if (num.im !== 0) return null;
126
127 const re = num.bignumRe ?? num.re;
128 if (typeof re === 'number' && isNaN(re)) return null;
129 return expr.engine.bignum(re);
130}
131
132/**

Callers 1

evaluateGcdLcmFunction · 0.90

Calls 3

isNumberFunction · 0.90
isNaNFunction · 0.85
bignumMethod · 0.45

Tested by

no test coverage detected