huge regactoring

This commit is contained in:
Borys Levytskyi
2015-04-02 22:53:06 +03:00
parent 0b3e0ed4fb
commit cadafab3ec
15 changed files with 418 additions and 291 deletions

23
app/bitwise/calc.js Normal file
View File

@@ -0,0 +1,23 @@
(function(app, should){
var calc = {};
calc.numberOfBits = function(num) {
should.bePositiveInteger(num);
return Math.floor(Math.log(num) / Math.log(2)) + 1;
};
calc.maxNumberOfBits = function () {
var counts = [], num;
for(var i=0;i<arguments.length; i++)
{
num = arguments[i];
counts.push(this.numberOfBits(num));
}
return Math.max.apply(null, counts);
};
app.service('calc', calc);
})(window.app, window.should);