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

Function exactRealComponent

src/compute-engine/boxed-expression/box.ts:952–967  ·  view source on GitHub ↗

* The exact real component (`rational · √radical`) of a boxed expression that * is an exact real number literal, or `null`. Used to reconstruct exact * complex values when boxing `['Complex', re, im]`.

(
  op: Expression
)

Source from the content-addressed store, hash-verified

950
951 // If canonical, handle cases of various expression structures being able to
952 // be cast as BoxedNumbers (some cases of Negate, Rational, Divide, Complex),
953 // or 'de-number' some 'borderline invalid' boxed number-like expressions
954 // (!@note: this procedure is similarly repeated within the 'number'
955 // CanonicalForm, but the numberForm variant more simply applies to fully
956 // BoxedExprs., and during partial canonicalization only)
957 //
958 // Skipped when a user definition shadows the head (`function Divide(x, y)
959 // { … }`): the fold would answer the library operator's value, not the
960 // user's (see `shadowsLibraryName`, `library-shadowing.ts`).
961 if (
962 canonicalNumber &&
963 !(
964 (name === 'Divide' ||
965 name === 'Rational' ||
966 name === 'Complex' ||
967 name === 'Negate') &&
968 shadowsLibraryName(ce, name)
969 )
970 ) {

Callers 1

boxFunctionFunction · 0.85

Calls 2

isNumberFunction · 0.90
isIntegerMethod · 0.45

Tested by

no test coverage detected