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

Function roundToSignificantDigits

src/compute-engine/library/core.ts:1711–1732  ·  view source on GitHub ↗

* Round a numeric result to `p` significant digits at the *value* level, so * the returned number genuinely carries `p` digits (independent of whatever * precision a downstream consumer serializes at). Used by `N(expr, p)` when * the requested precision is at or below the engine's working precisi

(value: Expression, p: number)

Source from the content-addressed store, hash-verified

1709 * target rides as type-expression SOURCE (like `DeclareType`'s body) and the
1710 * implementation block, when present, is stored RAW (phase 2 validates it
1711 * against the protocol's requirements).
1712 *
1713 * The optional `where` operand is the trailing clause of a CONDITIONAL
1714 * conformance, as SOURCE TEXT (`{str: "where T is Comparable"}`) — the P11
1715 * pattern `DeclareType`'s `typeParams` attribute uses, re-parsed by the engine.
1716 * It is told apart from the implementation block by its HEAD: a clause is a
1717 * string, a block a `Dictionary` (the same by-head rule `DeclareSumType` uses
1718 * for its attributes bag).
1719 */
1720function declareConformanceStatement(
1721 ce: ComputeEngine,
1722 targetOp: Expression | undefined,
1723 protocolsOp: Expression | undefined,
1724 whereOrImplOp: Expression | undefined,
1725 implOp: Expression | undefined
1726): Expression | null {
1727 const target = declarationName(targetOp);
1728 if (!target)
1729 return ce.error([
1730 'protocol-conformance-target-invalid',
1731 'Expected a conformance target type',
1732 ]);
1733
1734 if (notAtTopLevel(ce))
1735 return ce.error(

Callers 1

core.tsFile · 0.85

Calls 5

complexMethod · 0.80
toPrecisionMethod · 0.80
numberMethod · 0.65
isFiniteMethod · 0.45
bignumMethod · 0.45

Tested by

no test coverage detected