Answers for "binary function"

0

binary function

String.prototype.bin = function () {
        return parseInt(this, 2);
    };
    Number.prototype.bin = function () {
        var sign = (this < 0 ? "-" : "");
        var result = Math.abs(this).toString(2);
        while(result.length < 32) {
            result = "0" + result;
        }
        return sign + result;
    }

//result
console.log("110".bin())
//00000000000000000000000000000110
console.log(6..bin())
//6
Posted by: Guest on March-05-2022

Code answers related to "binary function"

Code answers related to "Javascript"

Browse Popular Code Answers by Language