Dave's Brain

Browse - Programming Tips - How can I convert a number to hex (hexadecimal)?

Date: 2014oct13
Language: javaScript

Q.  How can I convert a number to hex (hexadecimal)?

A.  Its built-in to the language:

var num = 255; var asHex = num.toString(16); // becomes base-16 (hex) console.log("num is " + asHex + " in hex");

Add a comment

Sign in to add a comment
Copyright © 2008-2017, dave - Code samples on Dave's Brain is licensed under the Creative Commons Attribution 2.5 License. However other material, including English text has all rights reserved.