PDA

View Full Version : How do you convert numbers between different bases in JavaScript ?



Sankara Vignesh
10-09-2017, 09:02 AM
Please share your opinion about the converting of numbers between the different bases in JavaScript....!

Glow
10-20-2017, 10:36 AM
Personally I have been extremely and painlessly satisfied dealing with Linovus.ca web development services (http://www.linovus.ca).
They have top-notch customer service, responding to trouble tickets immediately and consistently. Contact them if you need to solve any problems.

bangalorewebgur
12-07-2019, 09:37 AM
By using the parseInt() function, we can convert numbers between different bases in JavaScript. This function takes a string as the first parameter, and the base as a second parameter


Web Design Company in Bangalore (https://www.bangalorewebguru.in) | Web Development Company in Bangalore (https://www.bangalorewebguru.in) | Website Development Company in Bangalore (https://www.bangalorewebguru.in) | Website Design Company in Bangalore (https://www.bangalorewebguru.in)

shaili shah
04-09-2020, 02:13 AM
To convert hex string to number then parseInt(string, radix) is used.
To convert number to hex string then object.tostring(radix) is used.

radix is a base. It's value is 2,8,16...etc.

Integer to hex :

Example :

var i = 10;
console.log( i.toString(16) );

output : a

Hex string to int :

var h = "a";
console.log( parseInt(h, 16) );

output : 10

I hope this'll help you.