Monday 24 April 2017

hex - How to convert decimal to hexadecimal in JavaScript



How do you convert decimal values to their hexadecimal equivalent in JavaScript?


Answer



Convert a number to a hexadecimal string with:



hexString = yourNumber.toString(16);



And reverse the process with:



yourNumber = parseInt(hexString, 16);

No comments:

Post a Comment

c++ - Does curly brackets matter for empty constructor?

Those brackets declare an empty, inline constructor. In that case, with them, the constructor does exist, it merely does nothing more than t...