Socket
Socket
Sign inDemoInstall

hex2dec

Package Overview
Dependencies
0
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

hex2dec

Arbitrary precision decimal/hexadecimal converter.


Version published
Maintainers
1
Created

Package description

What is hex2dec?

The hex2dec npm package provides utilities for converting hexadecimal numbers to decimal and vice versa. It is useful for applications that need to handle numerical data in different bases, particularly in fields like computer science, electronics, and data encoding.

What are hex2dec's main functionalities?

Hexadecimal to Decimal Conversion

This feature allows you to convert a hexadecimal string to its decimal equivalent. In the example, the hexadecimal '1A' is converted to the decimal number 26.

const hex2dec = require('hex2dec');
const decimal = hex2dec.hexToDec('1A');
console.log(decimal); // Output: 26

Decimal to Hexadecimal Conversion

This feature allows you to convert a decimal number to its hexadecimal string equivalent. In the example, the decimal number 26 is converted to the hexadecimal '1A'.

const hex2dec = require('hex2dec');
const hex = hex2dec.decToHex(26);
console.log(hex); // Output: '1A'

Other packages similar to hex2dec

Readme

Source

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.

Keywords

FAQs

Package last updated on 12 Jan 2019

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc