hex2dec
Arbitrary precision decimal↔️hexadecimal converter, from a blog post by Dan Vanderkam. Supports non-negative integer values.
Usage
npm install --save hex2dec
var converter = ; var dec = converter; // 250var hex = converter; // '0xfa'var hexString = converter; // 'fa'
Why use hex2dec
(250).toString(16) === 'fa'
and 250 === 0xFA
both work just fine, and will provide enough precision for most uses. For large (>64-bit) numbers, however, precision is lost. This utility provides a higher-precision alternative.
License
This code may be used under the Apache 2 license.