Convert from type X to type Y

A string to integer
  
s = "12";
i = parseInt(s, 10);  

OR  

i = evasl(s)    

OR  

i = s - 0;
An integer to a string
  
i = 12;
s = (i).toString();   

or   

s = "" + i;  
  
(hex string)  s = "0x" + (i).toString(16);
(oct string)  s = "0"  + (i).toString(8);  
(bin string)  s = (i).toString(2);



If you find this article useful, consider making a small donation
to show your support for this Web site and its content.

Written and compiled by Réal Gagnon ©1998-2010
[ home ]