Welcome to WebmasterWorld Guest from

Forum Moderators: open

Message Too Old, No Replies

javascript help




4:43 am on Apr 3, 2010 (gmt 0)

5+ Year Member

How do you convert numbers between different bases in javascript? Can anybody help me on this.


6:37 am on Apr 3, 2010 (gmt 0)

5+ Year Member

Number.toString(rdx) accepts a radix parameter (the radix parameter must be an integer between 2 and 36):
var n = 11111111;
alert(n.toString(2)); //binary
alert(n.toString(10)); //decimal
alert(n.toString(16)); //hexadecimal

parseInt(s,rdx) also takes a radix parameter as it's second argument for going from string to number:
var nS = 'a98ac7';
alert(parseInt(nS, 16));

Featured Threads

Hot Threads This Week

Hot Threads This Month