Giter Club home page Giter Club logo

float-compute-patch's Introduction

float-compute-patch

float-compute-patch Build Status

patch v8 float compute lose precision

translations

δΈ­ζ–‡

useful if you

  • your system has floating-point operations
  • involve some amount calculation

install

npm install --save float-compute-patch

usage

// without patch 2.2+2.1 in v8 = 4.300000000000001. and so on,there are many problems
/*
***
  version 1.x
***
*/
// just execute once at your entry program for expample app.js
require('float-compute-patch');
// write like below
var result = 2.2.add(2.1); // = 4.3 or write like this (2.2).add(2.1)
// support chain write
var result = 2.2.add(2.1).sub(0.5).div(1).mul(2);
/*
***
  version 2.0.0
***
*/
// if you just want to add it to the Number prototype
require('float-compute-patch').patch(); // like the v1 version
// if you just want to use an ordinary function
var cal = require('float-compute-patch').cal;
// write like below
var result = cal(2.2).add(2.1).sub(8);

api

  • mode of patch Number prototype, you should start with a number

    • add(number), addition
    • sub(number), subtraction
    • mul(number), multiplication
    • div(number), division
  • mode of ordinary function, you should start with cal(number)

    • add(number), addition
    • sub(number), subtraction
    • mul(number), multiplication
    • div(number), division

test

npm test

float-compute-patch's People

Contributors

dtboy1995 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Forkers

jasenpan1987

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.