Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

number-converter

Package Overview
Dependencies
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

number-converter

Converts numbers between various formats

  • 1.2.1
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

number-converter

npm version Build Status Dependency Status devDependency Status

A Node.js library for converting between different numeric representations.

Usage

var NumberConverter = require("number-converter").NumberConverter;

var nc = new NumberConverter(NumberConverter.DECIMAL, NumberConverter.ROMAN_NUMERAL);
console.log(nc.convert(1234)); // MCCXXXIV
console.log(nc.deconvert("MCMXCIX")); // 1999

Number Types

A NumberConverter can convert between different numeric representations specified in its constructor. To convert between hexadecimal and binary, write:

var nc = new NumberConverter(NumberConverter.HEXADECIMAL, NumberConverter.BINARY);
console.log(nc.convert("F8F")); // "111110001111"

Here are the available number types:

  • NumberConverter.DECIMAL - Base-10 number system (digits 0-9)
  • NumberConverter.BINARY - Base-2 number system (digits 0 and 1)
  • NumberConverter.OCTAL - Base-8 number system (digits 0-7)
  • NumberConverter.HEXADECIMAL - Base-16 number system (digits 0-9 and letters A-F)
  • NumberConverter.ROMAN_NUMERAL - Numeric system used in ancient Rome (letters I, V, X, L, C, D and M)
  • NumberConverter.SCIENTIFIC_NOTATION - Scientific notation: a way of writing numbers too large or small to be conveniently written as decimal (e.g. 5200000 -> 5.2e6)

Installation

To use number-converter in your Node.js project, run:

npm install number-converter --save

Other Topics

Keywords

FAQs

Package last updated on 30 Mar 2016

Did you know?

Socket

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.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc