(lhs: Rational, rhs: Rational)
| 206 | } |
| 207 | |
| 208 | export function rationalGcd(lhs: Rational, rhs: Rational): Rational { |
| 209 | if (isMachineRational(lhs) && isMachineRational(rhs)) { |
| 210 | if (lhs[1] === 1 && rhs[1] === 1) return [gcd(lhs[0], rhs[0]), 1]; |
| 211 | return [gcd(lhs[0], rhs[0]), lcm(lhs[1], rhs[1])]; |
| 212 | } |
| 213 | |
| 214 | if (lhs[1] === 1 && rhs[1] === 1) |
| 215 | return [bigGcd(BigInt(lhs[0]), BigInt(rhs[0])), BigInt(1)]; |
| 216 | |
| 217 | return [ |
| 218 | bigGcd(BigInt(lhs[0]), BigInt(rhs[0])), |
| 219 | bigLcm(BigInt(lhs[1]), BigInt(rhs[1])), |
| 220 | ] as Rational; |
| 221 | } |
| 222 | |
| 223 | // export function rationalLcm( |
| 224 | // [a, b]: [number, number], |
no test coverage detected