You're here: Snippet Directory » HTML/JavaScript (65)
Language:

hex

Language: English
Programming Language: JavaScript
Published by: beernut [not registered]
Last Update: 5/15/2006
Views: 667


Description

Convert a number to a hex string.

Code

1 function hex(n){ 2 var hex="0123456789abcdef", str = "#"; 3 for(var i = 5; i >= 0; i--) str += hex.charAt((n >> (i * 4)) & 0xf); 4 return str; 5 } 6

No comments avaiable

Add a comment

Name *  

Email (won't be displayed) *    

Website  

Comment *  

Sicherheitscode Security Code *    

RSS