hex2dec

Arbitrary precision decimal/hexadecimal converter.

Apache-2.0 5 个版本
安装
npm install hex2dec
yarn add hex2dec
pnpm add hex2dec
bun add hex2dec
README

hex2dec

Latest NPM release Minzipped size License Build Status

Arbitrary precision decimal↔️hexadecimal converter, from a blog post by Dan Vanderkam. Supports non-negative integer values.

Usage

npm install --save hex2dec
var converter = require('hex2dec');

var dec = converter.hexToDec('0xFA'); // 250
var hex = converter.decToHex('250'); // '0xfa'
var hexString = converter.decToHex('250', { prefix: false }); // '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.

版本列表
1.1.2 2019-01-12
1.1.1 2018-12-04
1.1.0 2018-09-14
1.0.1 2016-07-10
1.0.0 2016-07-10