mirror of
https://github.com/BorysLevytskyi/BitwiseCmd.git
synced 2025-12-23 13:12:42 +01:00
Implemented historical commands
This commit is contained in:
@@ -1,23 +1,21 @@
|
||||
(function(app, should){
|
||||
var calc = {};
|
||||
app.component('calc', {
|
||||
|
||||
calc.numberOfBits = function(num) {
|
||||
should.bePositiveInteger(num);
|
||||
return Math.floor(Math.log(num) / Math.log(2)) + 1;
|
||||
};
|
||||
numberOfBits: function (num) {
|
||||
should.bePositiveInteger(num);
|
||||
return Math.floor(Math.log(num) / Math.log(2)) + 1;
|
||||
},
|
||||
|
||||
calc.maxNumberOfBits = function (arr) {
|
||||
maxNumberOfBits: function (arr) {
|
||||
|
||||
var counts = [], num;
|
||||
for(var i=0;i<arr.length; i++)
|
||||
{
|
||||
num = arr[i];
|
||||
counts.push(this.numberOfBits(num));
|
||||
var counts = [], num;
|
||||
for (var i = 0; i < arr.length; i++) {
|
||||
num = arr[i];
|
||||
counts.push(this.numberOfBits(num));
|
||||
}
|
||||
|
||||
return Math.max.apply(null, counts);
|
||||
}
|
||||
|
||||
return Math.max.apply(null, counts);
|
||||
};
|
||||
|
||||
app.service('calc', calc);
|
||||
});
|
||||
|
||||
})(window.app, window.should);
|
||||
|
||||
Reference in New Issue
Block a user