Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

frac

Package Overview
Dependencies
Maintainers
1
Versions
12
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

frac

Rational approximation with bounded denominator

  • 1.0.4
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
2M
decreased by-17.59%
Maintainers
1
Weekly downloads
 
Created

What is frac?

The frac npm package is designed to compute the fractional part of a number, effectively separating the integer part from the decimal part of a number. This can be particularly useful in mathematical, engineering, or scientific applications where precision with decimal numbers is required.

What are frac's main functionalities?

Fractional Part Extraction

This feature allows you to extract the fractional part of a number. The function returns an array where the first element is the decimal fraction, the second is the numerator, the third is the denominator, and the fourth is the sign.

const frac = require('frac');

let result = frac(4.567);
// result will be [0.567, 567, 1000, 3] representing the fraction, numerator, denominator, and sign.

Handling Negative Numbers

The package can also handle negative numbers, returning the fractional part along with the sign, which can be useful for applications that need to distinguish between positive and negative fractions.

const frac = require('frac');

let result = frac(-2.345);
// result will be [-0.345, 345, 1000, -1] indicating the fraction, numerator, denominator, and sign for negative numbers.

Other packages similar to frac

Keywords

FAQs

Package last updated on 16 Jan 2016

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc