homepage Welcome to WebmasterWorld Guest from 54.204.90.135
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member
Home / Forums Index / Code, Content, and Presentation / JavaScript and AJAX
Forum Library, Charter, Moderator: open

JavaScript and AJAX Forum

    
javascript help
conversion
bizminder




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

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

 

astupidname




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

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));

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Code, Content, and Presentation / JavaScript and AJAX
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved