Product
Introducing License Enforcement in Socket
Ensure open-source compliance with Socket’s License Enforcement Beta. Set up your License Policy and secure your software!
any-to-any
Advanced tools
The purpose of this module is to convert numbers from any base to other base you want.
Limitation
This module can convert only the integers numbers between base 2 & base 36. Soon, it will be possible to convert real numbers [wip].
Installation
# npm ..
$ npm install any-to-any
# yarn ..
$ yarn add any-to-any
Usage
This is a practical example of how to use.
// const convert = require('any-to-any')
const { convert } = require("any-to-any");
const inputNumber = "1110111"; // 119 in decimal
const inputBase = 2;
const outputBase = 8;
const result = convert(inputNumber, inputBase, outputBase);
console.log(result);
// 167
// NOTE: in case the input number is consists of numbers only,
// you can enter the number to the function in number type ..
const inputNumber = 1110111; // 119 in decimal
const inputBase = 2;
const outputBase = 8;
const result = convert(inputNumber, inputBase, outputBase);
console.log(result);
// 167
Also, we have 2 exported methods to convert a value from any base to Decimal (base 10) called anyBaseToDecimal
and the reverse one from Decimal to any base named decimalToAnyBase
.
NOTE: There are a set of suggested examples that have been tested that you can follow here.
Note about the new experimental convert
:We export a new experimental method experimentalConvert
maybe to solve problem of large numbers between hexa and decimal and up to 64 base.
You can use it with careful until we release the next major release (v5.0.0).
Please, if you find any problem or you have suggestion to improve the experiance with this module feel free to open an issue.
License
4.2.1 (24 Apr 2022)
FAQs
convert numbers between bases (any base to any base) 🔀 ..
The npm package any-to-any receives a total of 288 weekly downloads. As such, any-to-any popularity was classified as not popular.
We found that any-to-any demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
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.
Product
Ensure open-source compliance with Socket’s License Enforcement Beta. Set up your License Policy and secure your software!
Product
We're launching a new set of license analysis and compliance features for analyzing, managing, and complying with licenses across a range of supported languages and ecosystems.
Product
We're excited to introduce Socket Optimize, a powerful CLI command to secure open source dependencies with tested, optimized package overrides.