Skip to content

Commit

Permalink
feat(pow): add pow function
Browse files Browse the repository at this point in the history
  • Loading branch information
javiercejudo committed Jul 18, 2015
1 parent 4b6eb91 commit 8c70e84
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/floating.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,10 @@ function factory() {
return new Floating(this.val() / x.val());
};

p.pow = function div(exponent) {
return new Floating(Math.pow(this.val(), exponent.val()));
};

p.toString = function toString() {
return this.val().toString();
};
Expand Down
5 changes: 5 additions & 0 deletions test/spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,11 @@ describe('Floating', function() {
it('should have a div method', function() {
new Floating(0.3).div(new Floating(0.2)).valueOf().should.be.exactly(0.3 / 0.2);
});

it('should have a pow method', function() {
new Floating(2).pow(new Floating(5)).valueOf().should.be.exactly(32);
new Floating(81).pow(new Floating(0.5)).valueOf().should.be.exactly(9);
});
});

describe('toString, valueOf and JSON', function() {
Expand Down

0 comments on commit 8c70e84

Please sign in to comment.