Docs
Getting Started

Docs

Getting Started

Examples

Installation

Node

Browser

Num

Constructor

toBase

toString

NumOptions

Num

Num is the main way of interacting with DecimalSystem. It wraps around a number (or numeric string) and provides features to convert to different bases. For example, to convert a number to base 16, you can do:

new Num(82).toBase(16).toString();

Constructor

new Num(options)

Create a new Num instance to do base conversions.

NameDescriptionTypeExample
optionsThe options for the num. This includes the number being wrapped, as well as information about it (such as its base).String/Number or NumOptions26

toBase

num.toBase(base)

Convert a Num to another base. Note that base conversions are only done in toString; this method simply sets the base that the Num will be converted to.

NameDescriptionTypeExample
baseThe base that the Num will be converted to.Number (greater than 1)16

toString

num.toString(precision?)

Turn a Num into a string. This may or may not be a valid Number, depending on the base used.

NameDescriptionTypeExample
precision?The maximum amount of decimal digits that will appear in the number. For example, if the default (8) is used, a number will always have 8 or fewer decimals.Number8