cnum

cnum

Comfortably Numbers (cnum) represents rational numbers and related mathematical expressions in a biginteresting way.

NPM Version NPM Downloads Build Status Build Size Code Coverage Scrutinizer Code Quality Language Grade GPL 3.0

Install

yarn add cnum

Usage

Build System

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

Node

const {Rat} = require('cnum')
const r = new Rat(7, 11)
r.profile

Script Tags

<script src="https://unpkg.com/cnum"></script>
<script>
const r = new cnum.Rat(4, 13)
console.log(r.profile)
</script>

Command Line Interface

$ cnum "(5/7) + (2/3) ^ (5/9)"
42352677594770199369/28000000000000000000

$ cnum
cnum> 2/7
2/7 (≈0.28571428571428571429)

CLI in Browser

RunKit

Read the Docs

Documentation

CLI Commands

  • yarn install: Install dependencies
  • yarn dev: Run tests when source files are changed
  • yarn lint --fix: Lint with ESLint
  • yarn test: Run tests
  • yarn doc: Build documentation
  • yarn build: Production build
  • yarn prepublish: Prepare for publishing
  • yarn publish: Publish to npm

Feedback

Sponsorship

Generated using TypeDoc