Unleash numerical mystique with this npm package, effortlessly converting between binary, octal, decimal, and hexadecimal bases.
npm install base-conversions
(or)
yarn add base-conversions
For .mjs or "type":"module"
import { decToBase, baseToDec, binToDec, decToBin, binToOct, binToHex, decToHex, decToOct, octToBin, octToDec, octToHex, hexToDec, hexToBin, hexToOct } from 'base-conversions';
For .cjs or commonJs modules
const { decToBase, baseToDec, binToDec, decToBin, binToOct, binToHex, decToHex, decToOct, octToBin, octToDec, octToHex, hexToDec, hexToBin, hexToOct } = require('base-conversions');
// Convert decimal to binary
const binary = decToBin(13);
console.log('Decimal to Binary:', binary); // Output: 1101
// Convert binary to decimal
const decimalOutput = binToDec(1101);
console.log('Binary to Decimal:', decimalOutput); // Output: 13
Converts a decimal number to any base.
Converts a number from any base to decimal.
Converts a binary number to decimal.
Converts a decimal number to binary.
Converts a binary number to octal.
Converts a binary number to hexadecimal.
Converts a decimal number to hexadecimal.
Converts a decimal number to octal.
Converts an octal number to binary.
Converts an octal number to decimal.
Converts an octal number to hexadecimal.
Converts a hexadecimal number to decimal.
Converts a hexadecimal number to binary.
Converts a hexadecimal number to octal.