“hex decima ke biner js” Kode Jawaban

javascript hex ke biner

function hex2bin(hex){
    return ("00000000" + (parseInt(hex, 16)).toString(2)).substr(-8);
}
Yasin

hex decima ke biner js

function hex2bin(hexSource) {
    var bin = '';
    for (var i=0;i<hexSource.length;i=i+2) {
        bin += String.fromCharCode(hexdec(hexSource.substr(i,2)));
    }
    return bin;
}

function hexdec(hexString) {
    hexString = (hexString + '').replace(/[^a-f0-9]/gi, '')
    return parseInt(hexString, 16)
}
Restu Wahyu Saputra

hex decima ke biner js

/* Convert value as 8-bit unsigned integer to 2 digit hexadecimal number. */

function hex8(val) {
    val &= 0xFF;
    var hex = val.toString(16).toUpperCase();
    return ("00" + hex).slice(-2);
}

/* Convert value as 16-bit unsigned integer to 4 digit hexadecimal number. */

function hex16(val) {
    val &= 0xFFFF;
    var hex = val.toString(16).toUpperCase();
    return ("0000" + hex).slice(-4);
}

/* Convert value as 32-bit unsigned integer to 8 digit hexadecimal number. */

function hex32(val) {
    val &= 0xFFFFFFFF;
    var hex = val.toString(16).toUpperCase();
    return ("00000000" + hex).slice(-8);
}


var num = 1065489844;
console.log("0x" + hex32(num)); // will output 0x3F8215B4 
Restu Wahyu Saputra

Jawaban yang mirip dengan “hex decima ke biner js”

Pertanyaan yang mirip dengan “hex decima ke biner js”

Lebih banyak jawaban terkait untuk “hex decima ke biner js” di JavaScript

Jelajahi jawaban kode populer menurut bahasa

Jelajahi bahasa kode lainnya