Easy and Flexible Hexadecimal Conversion in JavaScript
Easy and Flexible Hexadecimal Conversion in JavaScript
Recently, I came across someone asking about converting a number to its hexadecimal equivalent using JavaScript. I just thought of sharing what I helped them with other readers since it involves a very simple function toString() in JavaScript but lesser known to all.
The following simple code snippet demonstrates the ease of conversion of decimal to hexadecimal in JavaScript:
<script language='Javascript'>
var intSrc = 25;
alert (intSrc.toString(16));
</script>
Other conversions:
Recently, I came across someone asking about converting a number to its hexadecimal equivalent using JavaScript. I just thought of sharing what I helped them with other readers since it involves a very simple function toString() in JavaScript but lesser known to all.
The following simple code snippet demonstrates the ease of conversion of decimal to hexadecimal in JavaScript:
<script language='Javascript'>
var intSrc = 25;
alert (intSrc.toString(16));
</script>
Other conversions:
- toString(2) establishes decimal to binary conversion
- toString(8) achieves decimal to octal conversion
Labels: javascript
![[Lavanya Deepak]](http://img.photobucket.com/albums/v31/vdeepakkumar/lvdp.gif)

![[Microsoft Certified Professional]](http://img12.photobucket.com/albums/v31/vdeepakkumar/mcp.gif)



0 Comments:
Post a Comment
Subscribe to Post Comments [Atom]
<< Home