3 ms·
var round = function(number){ var binary = number.toString(2); var hex = number.toString(16); var R = function(str){ return /^10*$/.
by sharkbrainguy 17y ago
var round = function(number){
var binary = number.toString(2);
var hex = number.toString(16);
var R = function(str){
return /^10*$/.test(str);
};
return R(binary) && R(hex);
};
That I wrote this just shows how special class I am... If a number is "round" in base-n that just means it's a power of n, and obviously all powers of 16 are also powers of 2.