Skip to content

Commit

Permalink
feat(calculator.ts): add inverse method
Browse files Browse the repository at this point in the history
  • Loading branch information
gfmio committed Mar 7, 2019
1 parent f5d30cb commit 0ed8578
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/Calculator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,4 +71,9 @@ export default class Calculator {
this.current = Math.tan(this.current);
return this;
}

public inverse() {
this.current = div(1, this.current);
return this;
}
}
2 changes: 2 additions & 0 deletions tests/Calculator.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,6 @@ describe("Calculator", () => {
it("can cos", () => expect(calculator.cos().value()).equal(1));
// prettier-ignore
it("can tan", () => expect(calculator.clear().tan().value()).equal(0));
// prettier-ignore
it("can invert", () => expect(calculator.clear().add(2).inverse().value()).equal(1 / 2));
});

0 comments on commit 0ed8578

Please sign in to comment.