@danielsimonjr/mathts-core 0.3.0 → 0.3.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/dist/index.js +11 -2
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -675,8 +675,17 @@ var Fraction = class _Fraction {
675
675
  numerator;
676
676
  denominator;
677
677
  constructor(numerator, denominator = 1n) {
678
- let num = typeof numerator === "bigint" ? numerator : BigInt(numerator);
679
- let den = typeof denominator === "bigint" ? denominator : BigInt(denominator);
678
+ const toRatio = (x) => {
679
+ if (typeof x === "number" && !Number.isInteger(x)) {
680
+ const f = _Fraction.fromNumber(x);
681
+ return [f.numerator, f.denominator];
682
+ }
683
+ return [typeof x === "bigint" ? x : BigInt(x), 1n];
684
+ };
685
+ const [pn, qn] = toRatio(numerator);
686
+ const [pd, qd] = toRatio(denominator);
687
+ let num = pn * qd;
688
+ let den = qn * pd;
680
689
  if (den === 0n) {
681
690
  throw new Error("Fraction denominator cannot be zero");
682
691
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@danielsimonjr/mathts-core",
3
- "version": "0.3.0",
3
+ "version": "0.3.1",
4
4
  "description": "Core types, utilities, and configuration for MathTS",
5
5
  "author": "Daniel Simon Jr.",
6
6
  "license": "MIT",