Skip to content

"Easily switch between different number systems: binary, octal, decimal, and hexadecimal with base-conversions npm package."

Notifications You must be signed in to change notification settings

Rudy9025/Base.Conversions

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 

Repository files navigation

Unleash numerical mystique with this npm package, effortlessly converting between binary, octal, decimal, and hexadecimal bases.

Installation

npm install base-conversions

(or)

yarn add base-conversions

Imports

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');

Usage

// 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

Functions

decToBase(inputNumber, inputBase)

Converts a decimal number to any base.

baseToDec(inputNumber, inputBase)

Converts a number from any base to decimal.

binToDec(binary)

Converts a binary number to decimal.

decToBin(decimal)

Converts a decimal number to binary.

binToOct(binary)

Converts a binary number to octal.

binToHex(binary)

Converts a binary number to hexadecimal.

decToHex(decimal)

Converts a decimal number to hexadecimal.

decToOct(decimal)

Converts a decimal number to octal.

octToBin(octal)

Converts an octal number to binary.

octToDec(octal)

Converts an octal number to decimal.

octToHex(octal)

Converts an octal number to hexadecimal.

hexToDec(hexadecimal)

Converts a hexadecimal number to decimal.

hexToBin(hexadecimal)

Converts a hexadecimal number to binary.

hexToOct(hexadecimal)

Converts a hexadecimal number to octal.

License

MIT

About

"Easily switch between different number systems: binary, octal, decimal, and hexadecimal with base-conversions npm package."

Topics

Resources

Stars

Watchers

Forks

Packages

No packages published