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

Function machineValue

src/math-json/utils.ts:289–301  ·  view source on GitHub ↗
(
  expr: MathJsonExpression | null | undefined
)

Source from the content-addressed store, hash-verified

287 * has a precision outside of the machine range.
288 */
289export function machineValue(
290 expr: MathJsonExpression | null | undefined
291): number | null {
292 if (typeof expr === 'number') return expr;
293
294 if (typeof expr === 'string' && matchesNumber(expr))
295 return machineValueOfString(expr);
296
297 // Strictly, expr.num should be a string, but we allow it to be a number
298 if (expr !== undefined && isNumberObject(expr)) return machineValue(expr.num);
299
300 return null;
301}
302
303/**
304 * Return a rational (numer over denom) representation of the expression,

Callers 15

serializeCortexFunction · 0.90
parse-cortex.tsFile · 0.90
serializeBaseFormFunction · 0.90
serializeNumberFunction · 0.90
boxFunctionFunction · 0.90
isSinglePowerDenominatorFunction · 0.90
wrapMethod · 0.90
grabItemFunction · 0.90
numeratorDenominatorFunction · 0.90
serializeRootFunction · 0.90

Calls 3

matchesNumberFunction · 0.85
machineValueOfStringFunction · 0.85
isNumberObjectFunction · 0.85

Tested by

no test coverage detected