JSPM

fractional

1.0.0
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 4139
  • Score
    100M100P100Q112952F
  • License MIT

fraction arithmetic

Package Exports

  • fractional

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (fractional) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

fractional

a fraction arithmetic library written in javascript.

npm install fractional

Usage

var Fraction = require('fractional').Fraction

// Create a new fraction with the new keyword:

(new Fraction(7,3)).multiply(new Fraction(1,2)).toString()
// 1 1/6

(new Fraction(7,3)).divide(new Fraction(1,2)).toString()
// 4 2/3

(new Fraction(3,10)).add(new Fraction(5,9)).toString()
// 77/90

(new Fraction(0.25)).add(new Fraction(1,6)).toString()
// 5/12

(new Fraction(0.35)).subtract(new Fraction(1,4)).toString()
// 1/10

It's basic arithmetic

Fractional provides a simple interface to add, subtract, multiply, and divide fractions.

Fractions are represented in most-normalized form.

License

MIT

Author

Erik Garrison erik.garrison@gmail.com