Git Product home page Git Product logo

anynumber's Introduction

AnyNumber 大数浮点数计算

下载 & 安装

该 Javascript 库 / 模块可以用于前端也可以用于后端 Nodejs 中。

  1. 直接下载anynumber.js,然后使用 <script>标签引入,可以得到全局函数 AnyNumber.

  2. 使用 npm 进行包管理,具体为:

    npm install anynumber

然后使用 require 引入模块

var AnyNumber = require("anynumber");

AnyNumber() 初始化

运行:AnyNumber(2.4e8)
// => '240000000'

toFormat() 返回格式化数值

运行:AnyNumber(1000000.123456).toFormat(2)
// => '1,000,000.12'

toFixed() 精确度小数点后n位

运行:AnyNumber(3.1415926535).toFixed(2)
// => '3.14'

toString() 返回字符串

运行:AnyNumber(1.2e3).toString()
// => '1200'

toNumber() 返回原生Number对象

运行:AnyNumber('1.28e3').toNumber()
// => 1280

add() 加法运算

运行:AnyNumber('0.1').add('0.2').value
// => '0.3'

subtract() 减法运算

运行:AnyNumber('100').subtract('0.5').value
// => '99.5'

multiply() 乘法运算

运行:AnyNumber('3').multiply('2').value
// => '6'

divide() 除法运算

运行:AnyNumber('100').divide('4').value
// => '25'

mod() 取余运算

运行:AnyNumber('10').mod('3').value
// => '1'

sqrt() 开方运算

运行:AnyNumber('16').sqrt().value
// => '4'

pow() 幂运算

运行:AnyNumber('10').pow('2').value
// => '100'

anynumber's People

Contributors

mumuy avatar

Stargazers

bosima avatar issues avatar Wade Bohmker avatar  avatar

Watchers

 avatar  avatar

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.