Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to convert decimal to hexadecimal in JavaScript

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

like image 208
Luke Smith Avatar asked Sep 11 '08 22:09

Luke Smith


People also ask

How do you use hexadecimal in JavaScript?

Uses of Hexadecimal Numbers in JavaScriptJavaScript supports the use of hexadecimal notation in place of any integer, but not decimals. As an example, the number 2514 in hex is 0x9D2, but there is no language-supported way of representing 25.14 as a hex number.

How do you convert decimal to hexadecimal in Java?

To convert decimal to hexadecimal, use any of the two methods i.e. Integer. toHexString() − It returns a string representation of the integer argument as an unsigned integer in base 16.

What is FFFF hex in decimal?

My book says the hexadecimal notation FFFF equals 65535 in decimal value.


1 Answers

Convert a number to a hexadecimal string with:

hexString = yourNumber.toString(16); 

And reverse the process with:

yourNumber = parseInt(hexString, 16); 
like image 128
Prestaul Avatar answered Sep 30 '22 14:09

Prestaul