Comfortably Numbers (cnum) represents rational numbers and related mathematical expressions in a biginteresting way.
yarn add cnum
import {Rat} from 'cnum'
// a = 71/7
const a = new Rat(71, 7)
// b = 35/113
const b = new Rat(35, 113)
// c = a⋅b
const c = a.mul(b)
c.toString() // 355/113
c.valueOf() // 3.1415929203539825
const {Rat} = require('cnum')
const r = new Rat(7, 11)
r.profile
<script src="https://unpkg.com/cnum"></script>
<script>
const r = new cnum.Rat(4, 13)
console.log(r.profile)
</script>
$ cnum "(5/7) + (2/3) ^ (5/9)"
42352677594770199369/28000000000000000000
$ cnum
cnum> 2/7
2/7 (≈0.28571428571428571429)
yarn install
: Install dependenciesyarn dev
: Run tests when source files are changedyarn lint --fix
: Lint with ESLintyarn test
: Run testsyarn doc
: Build documentationyarn build
: Production buildyarn prepublish
: Prepare for publishingyarn publish
: Publish to npm
- Report bug and feature requests as GitHub Issues