Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/nescalante/archi
Easy math with decimals in Javascript
https://github.com/nescalante/archi
Last synced: about 1 month ago
JSON representation
Easy math with decimals in Javascript
- Host: GitHub
- URL: https://github.com/nescalante/archi
- Owner: nescalante
- License: mit
- Created: 2015-06-05T21:59:04.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2017-08-01T01:31:44.000Z (over 7 years ago)
- Last Synced: 2024-12-01T10:02:36.567Z (about 1 month ago)
- Language: JavaScript
- Size: 11.7 KB
- Stars: 3
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: Readme.md
- License: License
Awesome Lists containing this project
README
# +archi [![Greenkeeper badge](https://badges.greenkeeper.io/nescalante/archi.svg)](https://greenkeeper.io/)
> Easy math with decimals for Javascript
![Archimedes](http://i.imgur.com/o22kQDq.jpg)
## Install
Using `npm`
```
npm install archi
```Using `bower`
```
bower install archi
```## Native simple Javascript sum
```js
0.1 + 0.2; // 0.30000000000000004;
0.3 - 0.1; // 0.19999999999999998;
```## Solving the issue with archi
```js
var archi = require('archi');
var num = +archi
.calc(0.1)
.plus(0.2)
.plus(0.1)
.minus(0.1); // 0.3
num === 0.3; // true
```## But, why the `+` ahead?
Do this to do a fast conversion from the `ArchiNumber` instance to the native `Number` type.
## Methods
- `.plus(num)`: current num + other num
- `.minus(num)`: current num - other num
- `.mod(num)`: current num % other num## License
MIT