1.0.0 • Published 6 years ago
fractional.js v1.0.0
Fractional
A simple, lightweight fraction library.
Getting Started
You can install fractional via npm:
npm install -s fractional.js
Or, if you plan to use it in the browser, you can use a cdn:
<script src="https://unpkg.com/fractional.js"></script>
Examples
let pi = new Fractional(22,7) // -> {n:22, d:7}
new Fractional(22/7) // -> {n:22, d:7}
new Fractional([22,7]) // -> {n:22, d:7}
pi.sub(3) // -> {n:1, d:7}
pi.sub(new Fractional(1,3)) // -> {n:59, d:21}
pi.mul(2) // -> {n:44, d:7}
pi.pow(3) // -> {n:10648, d:343}
pi.mul(2).sub(3/4) // -> {n:155, d:28}
pi.toString() // -> 22/7
pi.valueOf() // -> 3.14285714285714
1/10 + 2/10 // -> 0.30000000000000004
new F(1/10).add(2/10).valueOf() // -> 0.3
new F(1/10 + 2/10) // -> 0.3
Docs
The docs can be found on the github wiki.
Built With
0 dependencies!
Contributing
Please read CONTRIBUTING.md for details on our code of conduct, and the process for submitting pull requests to us.
Versioning
We use SemVer for versioning. For the versions available, see the tags on this repository.
Authors
- Lucas Gruwez - Initial work - lucasgruwez
See also the list of contributors who participated in this project.
License
This project is licensed under the MIT License - see the LICENSE for details
1.0.0
6 years ago