https://github.com/react-component/mini-decimal
https://github.com/react-component/mini-decimal
Last synced: 4 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/react-component/mini-decimal
- Owner: react-component
- License: mit
- Created: 2022-12-01T03:19:35.000Z (about 3 years ago)
- Default Branch: master
- Last Pushed: 2024-01-29T10:16:30.000Z (almost 2 years ago)
- Last Synced: 2025-08-15T07:41:54.582Z (4 months ago)
- Language: TypeScript
- Size: 24.4 KB
- Stars: 6
- Watchers: 5
- Forks: 2
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# @rc-component/mini-decimal
A mini decimal calculator which only support `add`, `multi` or compare operation for mini bundle size.
[![NPM version][npm-image]][npm-url] [](https://github.com/umijs/dumi) [![build status][github-actions-image]][github-actions-url] [![Codecov][codecov-image]][codecov-url] [![npm download][download-image]][download-url]
[npm-image]: http://img.shields.io/npm/v/@rc-component/mini-decimal.svg?style=flat-square
[npm-url]: http://npmjs.org/package/@rc-component/mini-decimal
[github-actions-image]: https://github.com/react-component/mini-decimal/workflows/CI/badge.svg
[github-actions-url]: https://github.com/react-component/mini-decimal/actions
[codecov-image]: https://img.shields.io/codecov/c/github/react-component/mini-decimal/master.svg?style=flat-square
[codecov-url]: https://codecov.io/gh/react-component/mini-decimal/branch/master
[download-image]: https://img.shields.io/npm/dm/@rc-component/mini-decimal.svg?style=flat-square
[download-url]: https://npmjs.org/package/@rc-component/mini-decimal
## Development
```bash
npm install
npm test
```
## Usage
```tsx
import getMiniDecimal from '@rc-component/mini-decimal';
// Add
getMiniDecimal('0.1').add('0.2').toString(); // 0.3
// Multi
getMiniDecimal('0.1').multi('0.2').toString(); // 0.02
// Negate
getMiniDecimal('0.1').negate().toString(); // -0.1
// Equal
getMiniDecimal('0.1').equal('0.1'); // true
getMiniDecimal('0.1').equal('0.2'); // false
// Less Equals
getMiniDecimal('0.1').lessEquals('0.2'); // true
getMiniDecimal('0.1').lessEquals('0.1'); // false
```