Number
The Number category supports conversions between number bases such as binary, octal, decimal, and hexadecimal.
Supported Bases
Section titled “Supported Bases”- binary (base 2)
- octal (base 8)
- decimal (base 10)
- hexadecimal (base 16)
Quick Example
Section titled “Quick Example”console.log(convert.value(255).from("decimal").to("hexadecimal")); // "ff"
console.log(convert.value("1010").from("binary").to("decimal")); // "10"
Common Conversions
Section titled “Common Conversions”Binary ↔ Decimal
Section titled “Binary ↔ Decimal”convert.value(10).from("decimal").to("binary"); // "1010"convert.value(10).from("binary").to("decimal"); // "1010"
Decimal ↔ Hexadecimal
Section titled “Decimal ↔ Hexadecimal”convert.value("a").from("hexadecimal").to("decimal"); // "10"convert.value(15).from("decimal").to("hexadecimal"); // "f"
Octal ↔ Decimal
Section titled “Octal ↔ Decimal”convert.value(77).from("octal").to("decimal"); // "63"convert.value(77).from("decimal").to("octal"); // "115"