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

biginteger.js

v1.0.1

Published

Big Integer Library for Javascript.

Downloads

6

Readme

bignumber.js

Big Integer Library for Javascript.

Requirement

  1. node.js
  2. npm

How to install

Open your terminal and execute the following command

npm install biginteger.js

The name of the repo and npm module are different because the repo name has already been taken in npm registry :(.

Features

Currently, library is capable of handling integers with the following operations.

  1. Addition
  2. Substraction
  3. Multiplication
  4. Division
  5. Modulo
  6. Power function.

The floating point functionality will be added soon.

Usage

Once you install the library you can start using it by importing it through require function.

  var BigNumber = require('bignumber').BigNumber;
  • Creating an instance of BigNumber:

    You can create an instance of BigNumber with new operator by providing initial numbers as a string or another instance of BigNumber object.

  var a = new BigNumber("1024"),
      b = new BigNumber(a);
  • Adding numbers:

    You can add numbers using add method of BigNumber object. The function accepts two parameters, number to be added and the optional 'times'. The optional 'times' parameter is used to add 'number' by one or more times.

  var a = new BigNumber("1024"), 
      b = new BigNumber("1000");
      
  a.add(b); // 2024
  a.add(b, 10); // 11024
  
  // adding two negative numbers results into an addition.
  a = new BigNumber("-5");
  b = new BigNumber("-5");
  a.add(b); // -10
  a.add(b, 3); // -20
  
  // adding one positive and negative number results into a subtraction.
  a = new BigNumber("-5");
  b = new BigNumber("5");
  a.add(b); // 0
  a.add(b, 3); // 10
  
  • Subtracting numbers:

    The library provides subtract function to carry out subtraction. The signature of the function is same as add. The sign of the result is properly handled by the function.

  var a = new BigNumber("5"),
      b = new BigNumber("1");
  
  a.subtract(b); // 4
  a.subtract(b, 6); // -1
  
  // subtracting a positive and a negative number results into an addition.
  a = new BigNumber("5");
  b = new BigNumber("-6");
  a.subtract(b); // 11
  
  // if the sign of variable 'a' in the above example is negative, 
  // the resulting operation will be subtraction and the 
  // result will be '1'
  a = new BigNumber("-5");
  b = new BigNumber("-6");
  a.subtract(b); // 1
  • Multiplication:

    Multiplication of numbers is done through multiply method of BigNumber instance. The function takes same number of parameters as add and subtract.

   var a = new BigNumber("8"),
       b = new BigNumber("2");
   
   a.multiply(b); // 16
   a.multiply(b, 3); // 64
   
   a = new BigNumber("-4");
   b = new BigNumber("8");
   
   a.multiply(b); // -32