Can I create a hexadecimal to decimal converter in meteor/node?

Hello,

I have a six months experience in node.js and right now I’m doing a freelancing project where my client wants me to create a hexadecimal to decimal and vice versa converter as an additional feature of the web application.

Honestly, i have very basic informaition about this number conversion, i studied it in the schools just to pass the examination. My question is, can I create such converter with htis framework?

You need one line of javascript to convert hexadecimal to decimal. You can even do it in your browser console

function hexToDec(hexString) {
  return parseInt(hexString, 16);
};
2 Likes

haha, lol. This piece actually worked!! I did the same thing for decimal to hexadecimal. Since, decimal is base-10, I wrote 10 instead of 16.

Thanks for your help, sir!

Hello sir,

this piece of code just works fine for small numbers but it does not work if I insert large numbers. Here, on my tool i will have to use convert the larger hex numbers typically more then 16 12 characters. My client gave me reference of this hexadecimal tool. i just scrapped the code and found out that they are using Bignumber.js:

Here is the code to get correct answer for larger numbers:

import { BigNumber } from ‘bignumber.js’;
var x = new BigNumber(this.text_value, 16)
var dectobin = x.toString(10);
this.ans = dectobin;

They are using vue.js in the code.