npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@dayspringpartners/big-number

v1.0.4

Published

big-number -- library of functions that provide arithmetic on big numbers

Downloads

11

Readme

Big Integer library module

A library providing a arbitrary length integer implementation for Node and browser javascript coding.
This library was put together as an implementation of Programming Praxis "Big Number" exercises in 2011.

@dayspringpartners/big-number

Installation

npm install @dayspringpartners/big-number --save

Usage

In Typescript

import { BigNumber } from '@dayspringpartners/big-number';

const oneThousand = new BigNumber(1000);
const bigger = new BigNumber(123456789);

console.log(bigger.add(oneThousand).toNumber());
console.log(oneThousand.add(5).toNumber());
console.log(oneThousand.subtract(oneThousand).toNumber());

In Javascript

const BigNumber = require('@dayspringpartners/big-number').BigNumber;

var oneThousand = new BigNumber(1000);
var bigger = new BigNumber(123456789);

console.log(bigger.add(oneThousand).toNumber());
console.log(oneThousand.add(5).toNumber());
console.log(oneThousand.subtract(oneThousand).toNumber());

Methods

constructor(number)

constructor(string)

constructor(BigNumber)

BigNumber.parseString(string)

Scan the string number representation and return a BigNumber. The scanned string can have two forms based on the forms used for number literals in PostScript (but more relaxed).

The first form is a string representing a decimal integer consisting of an optional sign followed by one or more decimal digits. The number is interpreted as a signed decimal integer and is converted to a BigNumber object.

The second form is a string representing a radix number and takes the form base#number, where base is a decimal integer in the range 2 through 36. The number is then interpreted in this base; it must consist of an optional sign followed by digits ranging from 0 to base - 1. Digits greater than 9 are represented by the letters A through Z (or a through z). The resulting number is treated as a signed integer and is converted to a BigNumber object. The notation is intended for specifying integers in a non-decimal radix, such as binary, octal, or hexadecimal.

toNumber()

toString(base, parsable)

Return text representation of the BigNumber object.

  • base is the base used to represent the integer value. base is an integer in the range 2 through 36. The default for base is 10.
  • parsable is an optional boolean value. If parsable is true the output text representation will have the form base#number (if base != 10). If parsable is false the output text representation will have the form number. The default for parsable is false.

isZero()

isNeg()

isPos()

isEven()

isOdd()

compareTo()

eq()

ne()

lt()

gt()

le()

ge()

abs()

neg()

sign()

add()

subtract()

multiply()

divide()

Contributing

In lieu of a formal styleguide, take care to maintain the existing coding style. Add unit tests for any new or changed functionality. Lint and test your code.

Install for development

$ git clone ....
$ npm install

Start testing with watch

$ npm run test:watch

Test, Lint and format

$ npm run test
$ npm run lint
$ npm run format

increment version (up-to-date working directory)

$ npm verion patch|minor|major

publish new version to npm

# have an up-to-date working directory
$ npm verion patch|minor|major
$ npm login
$ npm publish

Release History

  • 1.0.3 Fifth Release

    • Some refactoring of code and tests.
    • Changed the text representation of the value used by parseString and toString methods. The text representation is now based on the specification of integer literals used by PostScript language.
  • 1.0.2 Fourth Release

    Completed implementation with division and string representation parsing and printing.

  • 1.0.1 Third Release

    Changed implementation to be be in Typescript. Updated to a hosted npm package.

  • 0.2.0 Second Release

    Completed Programming Praxis excercise "Big Numbers: Addition, Subtraction, And Multiplication": May 31, 2011

  • 0.1.0 First Release

    Completed Programming Praxis excercise "Big Numbers: Getting Started": May 24, 2011