// Get binary representation let binary = decimal.toString(2); binary = binary.padStart(bitWidth, '0');
// Get byte array (big-endian by default) let hex = decimal.toString(16).padStart(Math.ceil(bitWidth / 4), '0'); let bytes = []; for (let i = 0; i < hex.length; i += 2) { bytes.push(parseInt(hex.substr(i, 2), 16)); } anirdesh converter
if (endianness === 'LE') { bytes.reverse(); } // Get binary representation let binary = decimal