![Oracle Drags Its Feet in the JavaScript Trademark Dispute](https://cdn.sanity.io/images/cgdhsj6q/production/919c3b22c24f93884c548d60cbb338e819ff2435-1024x1024.webp?w=400&fit=max&auto=format)
Security News
Oracle Drags Its Feet in the JavaScript Trademark Dispute
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
all-your-base
Advanced tools
Convert from one base to another
npm install all-your-base
npm link
from your local repo's root. The executable is named ayb
.
Use this in your own scripts and/or as a quick stand-alone command-line tool.
var ayb = require('all-your-base');
// convert 'abcdef', from base-16 to base-2
ayb.parseInt('abcdef', 16, 2)
// Or directly call the conversion methods
ayb.decToBin(22);
ayb.hexToDec('10000');
First, type npm link
from your local repo's root directory. The executable
is named ayb
. Name a method & space separate your arguments.
$ ayb parseInt 65536 10 16
10000
$ ayb hexToDec 10000
65536
base/radix | name | module's abbr. |
---|---|---|
base 2 | binary | bin |
base 8 | octal | oct |
base 10 | decimal | dec |
base 16 | hexadecimal | hex |
Here's an exhaustive list for your reference.
parseInt
The native parseInt
method will let you convert another base to base-10.
But the one provided in this module will let you convert to another base. It's
merely a wrapper for the other conversion methods.
ayb.parseInt(value, fromBase, toBase)
value
, String. The value in the base you want to convert.fromBase
, Number. Specify the base you are converting from.
undefined
, then it is assumed you
are converting from base-10toBase
, Number.Specify the base you are converting to.
For the following methods, pass in a numerical as a string.
binToDec
binToHex
binToOct
octToDec
octToBin
octToHex
decToBin
decToHex
decToOct
hexToDec
hexToBin
hexToOct
The pattern: [old]To[New]
[old]
is the first three letters of the base you are converting from.
[New]
is the first three letters of the base to convert to.
Notice, the function name is lowerCamelCased.
Learn more about different bases.
FAQs
convert from/to binary, octal, hexadecimal, decimal values
We found that all-your-base demonstrated a not healthy version release cadence and project activity because the last version was released 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.
Security News
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
Security News
The Linux Foundation is warning open source developers that compliance with global sanctions is mandatory, highlighting legal risks and restrictions on contributions.
Security News
Maven Central now validates Sigstore signatures, making it easier for developers to verify the provenance of Java packages.