1.1.1 • Published 3 years ago

float-to-fraction v1.1.1

Weekly downloads
-
License
ISC
Repository
github
Last release
3 years ago

A simple yet effective library to convert a float

3.6

To numerator/denominator

18/5

Written in C and exported to Node as a module.

npm install float-to-fraction 

In .js

const floatToFraction = require('float-to-fraction');

const float = 3.6;
const returnedArr = floatToFraction(float); //Returns [18, 5];

Note: the algorithm tries to find the smallest nominator/denominator relationship with the float applied. Most of the time the algorithm returns the correct fraction but it is not 100% accurate on every application, which depends on different factors like rational/irrational numbers and number of decimals.

The algorithm is based off: https://en.wikipedia.org/wiki/Continued_fraction

1.1.1

3 years ago

1.1.0

3 years ago

1.0.6

3 years ago

1.0.5

3 years ago

1.0.4

3 years ago

1.0.3

3 years ago

1.0.2

3 years ago

1.0.1

3 years ago

1.0.0

3 years ago