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

ieee745gamma

v1.0.1

Published

The gamma and log(gamma) function

Downloads

75

Readme

IEEE-754 compliant LogGamma function

The log(gamma) function in JavaScript as defined in IEEE-745.

browser support

Version

1.0.0

Introduction

This is a port of the implementation of lngamma by Sun Microsystems who published the original under the following license:

Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.

Developed at SunPro, a Sun Microsystems, Inc. business.
Permission to use, copy, modify, and distribute this
software is freely granted, provided that this notice
is preserved.

That license is compatible with the MIT license.

A normal gamma function is implemented, too, but only with Math.exp() which induces a large error, especially for larger numbers. See the examples for details.

To implement a better exponential function is planned for a later version.

Example

The correct results to 38 decimal digits in the comments

> var g = require('ieee745gamma')
> g.gamma(11)
3628800.0000000084      // 3628800.0000000000000000000000000000000
> g.gamma(171)
7.257415615308056e+306  // 7.2574156153079989673967282111292631147 E306
// errors of gamma due to Math.exp():
> g.lngamma(171)
706.5730622457874       // 706.57306224578734711072226272129831468
> g.lngamma(11)
15.104412573075518      // 15.104412573075515295225709329251070372
> g.lngamma(1000000)
12815504.569147611      // 12815504.569147611659976971785017113154
> g.lngamma(.0001)
9.210282658633961       // 9.2102826586339622584486579752729991548
> g.lngamma(3)
0.6931471805599453      // 0.69314718055994530941723212145817656808
> g.lngamma(3) - Math.log(2)
0                       // 0

Methods

gamma(x)

Returns exp(log(gamma(x))) for real x, x not a negative integer, over the range of ca. -177.6 <= x <= 171.7, Infinity otherwise.

lngamma(x)

Returns log(gamma(x)) for real x, x not a negative integer, over the range of ca. -10^14 <= x <= 10^305, Infinity otherwise.

Install

With npm do:

npm install ieee745gamma

License

MIT