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

float80

v1.1.0

Published

Read 80-bit Extended Floating Point Numbers from buffers

Downloads

2,527

Readme

float80

Read 80-bit Extended Floating Point Numbers from buffers

It turns out that there does not appear to be any way to read the extended precision floating point format in Javascript, aka "long doubles".

Until now, anyway.

Get it

Get this library with

$ npm install float80

Usage

>>> const {Float80} = require('float80')

>>> f = Float80.fromBytes([0x3f, 0xff, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00])

>>> f.toString()
1

>>> f.asNumber()
<BigNumber: [String: 1]>

The number parsed by Float80 is stored in a BigNumber instance, and exposed by the asNumber function.

Generating 80 bit floats

Here is a trivial C program that you can use to view how 80-bit floats are represented:

#include <stdio.h>

union {
  long double value;
  unsigned char bytes[10];
} dc;

int main(int argc, char ** argv) {
  int i;
  while(1) {
      printf("Enter long double: ");
      scanf("%Lf", &dc.value);
      for (i = 0; i < 10; ++i) {
         printf("%02x ", dc.bytes[9 - i]);
      }
      printf("\n");
  }
}

Bonus: 48-bit floats.

The weird 48-bit float parsing is available in Float48 class.

Same API as Float80.

License

MIT