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

bigfx

v1.0.3

Published

`BigFX` is a JavaScript decimal fixed-point number library with unlimited size, built on the native BigInt.

Downloads

5

Readme

bigfx

npm version

BigFX is a JavaScript decimal fixed-point number library with unlimited size, based on the native BigInt. It supports up to 15 digits of fractional precision, and is internally stored as a BigInt scaled by a factor of 1e+15. BigFX can work on both Node.js and the browser.

Installation

Using NPM:

npm install bigfx

On the browser:

<script src="https://raw.githubusercontent.com/nirvanasupermind/bigfx/main/bigfx.min.js" type="text/javascript"></script>

Example

var BigFX = require("bigfx");
console.log(new BigFX(36.9).add(45).mul(94).toFixed(6)); // 7698.600000
console.log(new BigFX(9007199254740991n).add(2).toString()); // 9007199254740993
console.log(BigFX.PI.neg().cos().toString()); // -1

API

  • constructor() - Creates a BigFX object equal to 0
  • constructor(number) - Creates a BigFX object from a number (precision may be lost)
  • constructor(bigint) - Creates a BigFX object from a BigInt
  • constructor(bigfx) - Creates a BigFX object from another BigFX object
  • clone() - Returns a clone of a BigFX object
  • neg() - Returns negation of a BigFX object
  • add(other) - Returns addition of two BigFX objects (converts other if needed)
  • sub(other) - Returns subtraction of two BigFX objects (converts other if needed)
  • mul(other) - Returns multiplication of two BigFX objects (converts other if needed)
  • div(other) - Returns division of two BigFX objects (converts other if needed)
  • mod(other) - Returns modulo of two BigFX objects (converts other if needed)
  • and(other) - Returns bitwise AND of two BigFX objects (converts other if needed, only works if both arguments are integers)
  • or(other) - Returns bitwise OR of two BigFX objects (converts other if needed, only works if both arguments are integers)
  • xor(other) - Returns bitwise XOR of two BigFX objects (converts other if needed, only works if both arguments are integers)
  • shl(other) - Returns left-shift of two BigFX objects (converts other if needed, only works if other is an integer)
  • shr(other) - Returns right-shift of two BigFX objects (converts other if needed, only works if other is an integer)
  • exp() - Returns e raised to the power of a BigFX object
  • log() - Returns natural logarithm of a BigFX object
  • pow(other) - Returns exponentiation of two BigFX objects (converts other if needed)
  • sqrt() - Returns the square root of a BigFX object
  • sin() - Returns the sine of a BigFX object
  • cos() - Returns the cosine of a BigFX object
  • tan() - Returns the tangent of a BigFX object
  • lt(other) - Checks if a BigFX object is less than another BigFX object
  • le(other) - Checks if a BigFX object is less than or equal to another BigFX object
  • gt(other) - Checks if a BigFX object is greater than another BigFX object
  • ge(other) - Checks if a BigFX object is greater than or equal to another BigFX object
  • eq(other) - Checks if a BigFX object is equal to another BigFX object
  • ne(other) - Checks if a BigFX object is not equal to another BigFX object
  • toNumber() - Converts a BigFX object to a number
  • toBigInt() - Converts a BigFX object to a BigInt
  • toScaledBigInt() - Converts a BigFX object to a BigInt scaled up by a factor of 1e+15 (the internal representation)
  • toString(radix = 10)- Converts a BigFX object to a string in the specified radix
  • toFixed(fractionDigits = 0)- Converts a BigFX object to a string with the specified number of fraction digits
  • toExponential()- Converts a BigFX object to a string in scientific notation format
  • static ZERO- A BigFX object with a value of 0
  • static ONE- A BigFX object with a value of 1
  • static PI- A BigFX object with a value of π
  • static E- A BigFX object with a value of e
  • static random()- Creates a BigFX object with a pseudo-random value between 0 and 1