decimal2fraction
TypeScript icon, indicating that this package has built-in type declarations

1.0.0 • Public • Published

decimal2fraction

A node.js typescript function to convert any decimal number to its respective fraction.

 

How to use

const decimal2fraction = require("decimal2fraction")

let fraction = decimal2fraction(-1.375, 2)
console.log(fraction)
//logs "{ num: -227, den: 165 }" because -227/165 = -1.3757575...

The function "decimal2fraction" wants 3 arguments:

  • The decimal to convert;
  • The repeating digits of the given decimal (default: 0);
  • A boolean value that represents whether to reduce the fraction to its lowest terms (default: true).

 

Changelog & Breaking Changes

  • v1.0.0
    - First commit.

 

Found a bug and/or need help?

Please open an issue on Github to request a change, report a bug or ask for help about something and i will gladly look into it.

If you like this library, consider giving it a star on Github. It means a lot :)

Package Sidebar

Install

npm i decimal2fraction

Weekly Downloads

1

Version

1.0.0

License

MIT

Unpacked Size

9.15 kB

Total Files

9

Last publish

Collaborators

  • zwolfrost