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 🙏

© 2025 – Pkg Stats / Ryan Hefner

@steve02081504/bigfloat

v0.0.1

Published

A simple JavaScript implementation of infinite precision arithmetic.

Readme

@steve02081504/bigfloat

A simple JavaScript library for arbitrary-precision arithmetic, also known as "bigfloat". This implementation is inspired by elc.

It allows you to work with very large numbers and high-precision decimals without floating-point inaccuracies. It represents numbers as fractions, enabling precise calculations.

Features

  • Infinite Precision: Numbers are stored as fractions (numerator and denominator) for maximum precision.
  • Basic Arithmetic: Supports addition, subtraction, multiplication, division, modulus, and power operations.
  • Comparisons: Accurately compare numbers.
  • String Conversion: Handles conversion to and from strings, including support for repeating decimals (e.g., 0.3[3]).
  • Expression Evaluation: Includes a built-in eval function to parse and compute mathematical expressions from a string.

Installation

npm install @steve02081504/bigfloat

Usage

Basic Operations

import { bigfloat } from '@steve02081504/bigfloat';

const a = bigfloat('10').div(bigfloat('3')); // 10/3
const b = new bigfloat('0.5'); // 1/2

console.log(a.toString()); // '3.[3]'
console.log(b.toString()); // '0.5'

// Addition
const sum = a.add(b);
console.log(sum.toString()); // '3.8[3]' (10/3 + 1/2 = 23/6)

// Multiplication
const product = a.mul(b);
console.log(product.toString()); // '1.[6]' (10/3 * 1/2 = 10/6)

// Negative numbers
const c = new bigfloat('-123.456');
console.log(c.neg().toString()); // '123.456'

Repeating Decimals

The library can parse and represent repeating (recurring) decimals using bracket notation [].

import { bigfloat } from '@steve02081504/bigfloat';

// Parse a repeating decimal
const repeating = bigfloat('0.[1]'); // 1/9
console.log(repeating.toString()); // '0.[1]'

const result = repeating.mul(bigfloat('9'));
console.log(result.toString()); // '1'

Expression Evaluation

Use the static bigfloat.eval() method to evaluate mathematical expressions from a string.

import { bigfloat } from './main.mjs';

const result1 = bigfloat.eval('1.2 * (3.4 + 5.6)');
console.log(result1.toString()); // '10.8'

const result2 = bigfloat.eval('(1/3) + (2/7)');
console.log(result2.toString()); // '0.[428571]' (13/21)

const result3 = bigfloat.eval('2**100');
console.log(result3.toString()); // '1267650600228229401496703205376'

Supported operators in eval:

  • +, -, *, /, %, ** (power)
  • ==, !=, <, >, <=, >=
  • &&, ||, ! (logical)
  • Parentheses () for grouping.

API

new bigfloat(value)

Creates a new bigfloat instance. value can be a string, number, or another bigfloat instance.

Arithmetic

  • .add(other)
  • .sub(other)
  • .mul(other)
  • .div(other)
  • .mod(other)
  • .pow(other)

Comparison

  • .equals(other)
  • .lessThan(other)
  • .greaterThan(other)
  • .compare(other): Returns 1 if greater, -1 if less, 0 if equal.

Other Methods

  • .neg(): Returns the negated value.
  • .abs(): Returns the absolute value.
  • .floor(): Returns the floor of the number.
  • .toString(): Converts the number to its string representation, using [] for repeating decimals.

Static Methods

  • bigfloat.eval(expression): Evaluates a mathematical expression string.
  • bigfloat.fromString(string): Creates a bigfloat from a string.