convert-base

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

Downloads in past

Stats

StarsIssuesVersionUpdatedCreatedSize
convert-base
300.1.08 years ago8 years agoMinified + gzip package size for convert-base in KB

Readme

convert-base Build Status
Convert from one base to another: Hex, Binary, Decimal, Octal

Install

Download the production versionmin or the development versionmax.
$ 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