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

@sctg/scientific-notation

v1.0.1

Published

A TypeScript library for converting numbers to various scientific notation formats

Readme

Scientific Notation Formatter

A TypeScript library for formatting numbers in various scientific notation representations including HTML, LaTeX, and MathML.

Features

  • Convert numbers to scientific notation with configurable precision
  • Multiple output formats:
    • Standard scientific notation (e.g., 1.23e6)
    • LaTeX (1.23 \times 10^{6})
    • MathML (<math><mrow><mn>1.23</mn><mo>×</mo><msup><mn>10</mn><mn>6</mn></msup></mrow></math>)
    • HTML (1.23 × 10<sup>6</sup>)
  • Precise control over significant figures
  • Standardized exponents (steps of 3)
  • Zero handling
  • Typescript types included

Installation

npm install @sctg/scientific-notation

Usage

import { ScientificNotation } from '@sctg/scientific-notation';

// Basic usage
const number = 1234567.89;
const precision = 4;

// Standard scientific notation
console.log(ScientificNotation.toScientificNotationString(number, precision));
// Output: "1.235e6"

// LaTeX format
console.log(ScientificNotation.toScientificNotationLatex(number, precision));
// Output: "1.235 \times 10^{6}"

// HTML format
console.log(ScientificNotation.toScientificNotationHTML(number, precision));
// Output: "1.235 × 10<sup>6</sup>"

// MathML format
console.log(ScientificNotation.toScientificNotationMathML(number, precision));
// Output: "<math><mrow><mn>1.235</mn><mo>×</mo><msup><mn>10</mn><mn>6</mn></msup></mrow></math>"

API Reference

toScientificNotation(value: number, precision?: number): ScientificNotationNumber

Converts a number to scientific notation components.

const result = ScientificNotation.toScientificNotation(1234.56, 3);
// Returns: { mantissa: 1.23, exponent: 3 }

toScientificNotationString(value: number, precision?: number): string

Returns a string representation in scientific notation.

toScientificNotationLatex(value: number, precision?: number): string

Returns a LaTeX formatted string.

toScientificNotationMathML(value: number, precision?: number): string

Returns a MathML formatted string.

toScientificNotationHTML(value: number, precision?: number): string

Returns an HTML formatted string.

Types

type ScientificNotationNumber = {
  mantissa: number;  // The coefficient
  exponent: number;  // The power of 10
};

Features

  • Standardizes exponents in steps of 3
  • Maintains precision with trailing zeros
  • Handles special cases (zero, small numbers)
  • Type-safe with TypeScript

Contributing

  1. Fork the repository
  2. Create your feature branch (git checkout -b feature/amazing-feature)
  3. Commit your changes (git commit -m 'Add some amazing feature')
  4. Push to the branch (git push origin feature/amazing-feature)
  5. Open a Pull Request

License

Copyright (c) 2024-2025 Ronan LE MEILLAT

This project is licensed under the GNU Affero General Public License v3.0 - see the LICENSE file for details.

Author

Ronan LE MEILLAT
SCTG Development

Related Projects