Using Number's toString() method in radix mode : Type Conversion : Number Data Type JAVASCRIPT TUTORIALS


JAVASCRIPT TUTORIALS » Number Data Type » Type Conversion »

 

Using Number's toString() method in radix mode









When using Number's toString() method in radix mode, it is possible to output the number using a different base, such as 2 for binary, 8 for octal, or 16 for hexadecimal.

This functionality is useful for dealing with numbers in HTML.

HTML uses hexadecimal representations for each color.








var iNum = 10;
alert(iNum1.toString(2));
alert(iNum1.toString(8));
alert(iNum1.toString(16));







HTML code for linking to this page:

Follow Navioo On Twitter

JAVASCRIPT TUTORIALS

 Navioo Number Data Type
» Type Conversion