Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/caojianping/tsx-calculator
TypeScript版本的计算器库,提供了简单的加、减、乘、除基本四则运算功能,同时解决了精度丢失的问题。
https://github.com/caojianping/tsx-calculator
calculator javascript typescript
Last synced: 9 days ago
JSON representation
TypeScript版本的计算器库,提供了简单的加、减、乘、除基本四则运算功能,同时解决了精度丢失的问题。
- Host: GitHub
- URL: https://github.com/caojianping/tsx-calculator
- Owner: caojianping
- License: mit
- Created: 2020-02-15T10:18:03.000Z (almost 5 years ago)
- Default Branch: master
- Last Pushed: 2023-03-30T08:02:55.000Z (over 1 year ago)
- Last Synced: 2024-10-06T01:47:57.290Z (about 1 month ago)
- Topics: calculator, javascript, typescript
- Language: JavaScript
- Homepage:
- Size: 4.88 KB
- Stars: 11
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# tsx-calculator
TypeScript 版本的计算器库,提供了简单的加、减、乘、除基本四则运算功能,同时解决了精度丢失的问题。
## Installing
Using npm:
```bash
$ npm install tsx-calculator
```## Example
```ts
import Calculator from 'tsx-calculator';// test for Calculator
Calculator.add(1, 2); // return 3;
Calculator.subtract(2, 1); // return 1;
Calculator.multiply(2, 5); // return 10;
Calculator.divide(12, 3); // return 4;
```## API
##### Calculator.add(num1: number, num2: number, precision: number = 0): number
##### Calculator.subtract(num1: number, num2: number, precision: number = 0): number
##### Calculator.multiply(num1: number, num2: number, precision: number = 0): number
##### Calculator.divide(num1: number, num2: number, precision: number = 0): number