Skip to content

Commit

Permalink
Change Fraction to RationalNumber
Browse files Browse the repository at this point in the history
  • Loading branch information
Nyoho committed Nov 13, 2024
1 parent 51a5ece commit de71f69
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 375 deletions.
4 changes: 2 additions & 2 deletions src/components/continued-fraction.test.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { Fraction } from './fraction';
import RationalNumber from './rational-number';
import { continuedFraction } from './continued-fraction';

test('0.5 is 1/2', () => {
const a = new Fraction(1, 2);
const a = new RationalNumber(1, 2);
const b = continuedFraction(0.5, 5);
expect(b.toString()).toBe(a.toString())
})
348 changes: 0 additions & 348 deletions src/components/fraction.js

This file was deleted.

25 changes: 0 additions & 25 deletions src/components/time.js
Original file line number Diff line number Diff line change
@@ -1,24 +1,3 @@
//import Fraction from './fraction'
import { Fraction } from './fraction'
import RationalNumber from './rational-number'

function continuedFraction(x) {
var a = x;
var b = a % 1;
var a0 = Math.round(a - b);
if (b == 0)
return a0;
a = 1/b;
b = a % 1;
var a1 = Math.round(a - b);
if (b == 0)
return new Fraction(a0*a1+1, a1);
a = 1/b;
b = a % 1;
var a2 = Math.round(a - b);
return new Fraction(a0*(a1*a2+1)+a2, a1*a2+1);
}

const Time = class {
constructor(date) {
this.date = date;
Expand All @@ -39,10 +18,6 @@ const Time = class {
} else {
this.humanString = "紀元前 " + Math.ceil(-d) + " 年"
}

this.fraction = continuedFraction(this.ratio);
this.numerator = this.fraction.numerator;
this.denominator = this.fraction.denominator;
}

static getDateString(dt) {
Expand Down

0 comments on commit de71f69

Please sign in to comment.