How to convert decimal to hexadecimal in JavaScript

后端 未结 27 2662
臣服心动
臣服心动 2020-11-21 23:05

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

27条回答
  •  暗喜
    暗喜 (楼主)
    2020-11-21 23:31

    Convert a number to a hexadecimal string with:

    hexString = yourNumber.toString(16);
    

    And reverse the process with:

    yourNumber = parseInt(hexString, 16);
    

提交回复
热议问题