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

Function pow

src/compute-engine/numerics/rationals.ts:185–198  ·  view source on GitHub ↗
(r: Rational, exp: SmallInteger)

Source from the content-addressed store, hash-verified

183 if (rhsNum === null) return lhs;
184
185 if (isBigRational(rhsNum)) {
186 lhs = [BigInt(lhs[0]), BigInt(lhs[1])];
187 return [rhsNum[1] * lhs[0] + rhsNum[0] * lhs[1], rhsNum[1] * lhs[1]];
188 }
189 if (isBigRational(lhs)) {
190 const bigRhs = [BigInt(rhsNum[0]), BigInt(rhsNum[1])];
191 return [bigRhs[1] * lhs[0] + bigRhs[0] * lhs[1], bigRhs[1] * lhs[1]];
192 }
193
194 const n =
195 (rhsNum[1] as number) * (lhs[0] as number) +
196 (rhsNum[0] as number) * (lhs[1] as number);
197 const d = (rhsNum[1] as number) * (lhs[1] as number);
198
199 if (n <= 9007199254740991 && n >= -9007199254740991 && d <= 9007199254740991)
200 return [n, d];
201

Callers

nothing calls this directly

Calls 3

assertMethod · 0.80
inverseFunction · 0.70
isIntegerMethod · 0.45

Tested by

no test coverage detected