Giter Club home page Giter Club logo

hex2dec's Introduction

hex2dec

Latest NPM release npm bundle 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.

hex2dec's People

Contributors

aarontam avatar dependabot[bot] avatar donmccurdy avatar kjin avatar ortichon avatar renovate-bot avatar renovate[bot] avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

hex2dec's Issues

Dependency Dashboard

This issue provides visibility into Renovate updates and their statuses. Learn more

Other Branches

These updates are pending. To force PRs open, click the checkbox below.

  • Update dependency trim to 0.0.3 [SECURITY]

  • Check this box to trigger a request for Renovate to run again on this repository

[Warning] Parsing integers through package

Just leaving this here, there seems to be an issue from your package where parsing integers through from decimal to hexadecimal returns the error below:

TypeError: str.split is not a function
    at parseToDigitsArray (/Users/bea/Desktop/cs/Amour4/node_modules/hex2dec/index.js:55:20)
    at convertBase (/Users/bea/Desktop/cs/Amour4/node_modules/hex2dec/index.js:66:16)
    at Object.decToHex (/Users/bea/Desktop/cs/Amour4/node_modules/hex2dec/index.js:91:13)
    at Object.execute (/Users/bea/Desktop/cs/Amour4/src/commands/rolecolor.js:80:33)
    at processTicksAndRejections (node:internal/process/task_queues:96:5)
    at async Object.execute (/Users/bea/Desktop/cs/Amour4/src/events/interactionCreate.js:11:17)

Suggested fix is to support integers, because obviously APIs such as Discord returns one, but a simple toString() addition to my integer in my code did the trick.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.