Socket
Book a DemoInstallSign in
Socket

@jaymw/decimal

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@jaymw/decimal

for simple number to operation with + - * /

1.0.2
latest
Source
npmnpm
Version published
Maintainers
1
Created
Source

decimal

数字的加减乘除,处理了精度损失的问题。

usage

import * as Decimal from '@jay/decimal';

1. 0.1 + 0.2;   // 0.30000000000000004
   Decimal.add(0.1,0.2);  //0.3
   Decimal.add(0.1,0.2,0.1);  //0.4
   
   
2. 0.7 - 0.3;  //0.39999999999999997
   Decimal.sub(0.7,0.3);  //0.4
   Decimal.sub(0.7,0.3,0.1); //0.3
   
   
3. 0.1 * 0.2;  //0.020000000000000004
   Decimal.multi(0.1,0.2);  //0.02
   Decimal.multi(0.1,0.2,0.5); //0.01
 
4. 0.3 / 0.4;  //0.7499999999999999
   Decimal.div(0.3,0.4);  //0.75	

API

方法(method)参数(parameters)结果(result)备注(remark)
add ( arguments )num1,num2...number所有参数相加
sub( arguments )num1,num2...number第一个参数作为被减数,其余参数作为减数
multi( arguments )num1,num2...number所有参数相乘
div(num1,num2)num1,num2numbernum1 / num2

Keywords

decimal

FAQs

Package last updated on 29 Oct 2019

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.