Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

convert-base

pasangsherpa2.6kMIT0.1.0

Convert from one base to another: Hex, Binary, Decimal, Octal

hex-to-dec, dec-to-hex, bin-to-hex, hex-to-bin, dec-to-bin, bin-to-dec, number-system

readme

convert-base Build Status

Convert from one base to another: Hex, Binary, Decimal, Octal

Install

Download the production version or the development version.

$ npm install --save convert-base
$ bower install --save convert-base

Usage

var ConvertBase = require('convert-base');
var converter = new ConvertBase();
converter.convert(16, 10, 2); // 10000
converter.convert(0xF, 16, 2); // 1111
<script type="text/javascript" src="https://raw.githubusercontent.com/pasangsherpa/convert-base/master/dist/convert-base.min.js"></script>
<script type="text/javascript"> 
      var converter = new ConvertBase();
    converter.convert(16, 10, 2); // 10000
    converter.convert(0xF, 16, 2); // 1111

</script>
Refer to test.js in test directory for more examples.

Documentation

ConvertBase()

Creates an instance of the converter.

Methods

.convert(number, from, to)

Converts a number from one base to another. Returns the result as a number for decimal base and string for others.

number

Type: int

the number to be converted.

from

Type: int

the base to be converted from.

to

Type: int

the base to be converted to.

License

MIT © Pasang Sherpa