Coder Social home page Coder Social logo

ts-fraction's Introduction

ts-fraction

Recreation from original project Fraction.js

Why:

  • Try create project that can be package into ES6 module.
  • Self learaning.

TODO: Functions to be completed

  • Fraction abs() TODO
  • Fraction neg() TODO
  • Fraction add(n) ✅
  • Fraction sub(n) ✅
  • Fraction mul(n) ✅
  • Fraction div(n) ✅
  • Fraction pow(exp) TODO
  • Fraction mod(n) TODO
  • Fraction mod() TODO
  • Fraction gcd(n) TODO
  • Fraction lcm(n) TODO
  • Fraction ceil([places=0-16]) TODO
  • Fraction floor([places=0-16]) TODO
  • Fraction round([places=0-16]) TODO
  • Fraction inverse() TODO
  • Fraction simplify([eps=0.001]) TODO
  • boolean equals(n) TODO
  • int compare(n) TODO
  • boolean divisible(n) TODO
  • double valueOf() TODO
  • String toString([decimalPlaces=15]) ✅
  • String toLatex(excludeWhole=false) TODO
  • String toFraction(excludeWhole=false) TODO
  • Array toContinued() TODO
  • Fraction clone() TODO

Testing

Library: jasmine

npm run test

Library: ts-node

ts-node-esm test1.ts

Copyright and licensing

Copyright (c) 2023, devilkazuya99 Licensed under the MIT license.

ts-fraction's People

Contributors

devilkazuya99 avatar

Watchers

 avatar

ts-fraction's Issues

Repeating decimal places

See this: https://github.com/rawify/Fraction.js#repeating-decimal-places

Fraction.js can easily handle repeating decimal places. For example 1/3 is 0.3333.... There is only one repeating digit. As you can see in the examples above, you can pass a number like 1/3 as "0.'3'" or "0.(3)", which are synonym. There are no tests to parse something like 0.166666666 to 1/6! If you really want to handle this number, wrap around brackets on your own with the function below for example: 0.1(66666666).

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.