![From Academia to Industry](https://cdn.sanity.io/images/cgdhsj6q/production/70501690bf807891573e259da9719cf24302c7e3-4288x2848.jpg?w=400&fit=max&auto=format)
Employee Spotlight
From Academia to Industry
Philipp Burckhardt recounts his journey from childhood computer fascinations, to building an e-learning platform at Carnegie Mellon University, and on to his current role at Socket.
any-to-any
Advanced tools
Changelog
5.0.0 (19 Jun 2024)
Readme
The purpose of this module is to convert numbers from any base to other base you want.
This module support both CommonJS and ES Modules.
Limitation
Next Feature(s)
convert().from().to()
| convert().from().to().get()
).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"
Also, we have 2 exported methods to convert a value from any base to Decimal (base 10) called fromAnyBaseToDecimalBase
and the reverse one from Decimal to any base named fromDecimalBaseToAnyBase
.
fromAnyBaseToDecimalBase
// const convert = require('any-to-any')
const { fromAnyBaseToDecimalBase } = require("any-to-any");
const inputNumber = "1110111"; // 119 in decimal
const inputBase = 2;
const result = fromAnyBaseToDecimalBase(inputNumber, inputBase);
console.log(result);
// "119"
fromDecimalBaseToAnyBase
// const convert = require('any-to-any')
const { fromDecimalBaseToAnyBase } = require("any-to-any");
const inputNumber = "119";
const outputBase = 2;
const result = fromDecimalBaseToAnyBase(inputNumber, outputBase);
console.log(result);
// "1110111"
NOTE: There are a set of suggested examples that have been tested that you can follow here.
Note about the new experimental convert on v4.2.x
Since we bump to v5.x.x, we remove the new experimental method experimentalConvert
because we
resolved the problem related to large numbers due to the JS number limitation to handle only 32bit
in one shot. We use BigInt
for that 🤫.
Please, if you find any problem or you have suggestion to improve the experiance with this module feel free to open an issue.
License
FAQs
convert numbers between bases (any base to any base) 🔀 ..
The npm package any-to-any receives a total of 240 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.
Employee Spotlight
Philipp Burckhardt recounts his journey from childhood computer fascinations, to building an e-learning platform at Carnegie Mellon University, and on to his current role at Socket.
Security News
Git dependencies in open source packages can introduce significant risks, including lack of version control, stability issues, dependency drift, and difficulty in auditing, making them potential targets for supply chain attacks.
Security News
Node.js has added experimental support for TypeScript, a move that highlights the growing importance of TypeScript in modern development.