Reputation: 1771
I have this hexadecimal in a nodejs Tcp Client
82380000000000000400000000000000
I have used parseint function to convert it to
1.73090408076117e+38
But i need to get its binary representation that is
10000010001110000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000
Ho can i get this binary representation from the above hexadecimal format?
Upvotes: 3
Views: 5797
Reputation: 62
Using the toString specifying the base as the parameter should make it. For example, if you want to convert it to a binary string, after parsing it to an integer:
var number = '82380000000000000400000000000000';
console.log(parseInt(number).toString(2));
In case you want an hexadecimal string, just use .toString(16);
If you don't want to parse the string with the number:
var number = 82380000000000000400000000000000;
console.log(number.toString(2));
Hope this helps.
Upvotes: 3