Skip to content

Commit

Permalink
update package.json and add example to README.md
Browse files Browse the repository at this point in the history
  • Loading branch information
Yaffle committed Aug 29, 2020
1 parent 851a1ef commit 051f8d3
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 2 deletions.
16 changes: 16 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,13 @@
# BigDecimal
a polyfill for decimal propocal - https://github.com/tc39/proposal-decimal
It is implemented on the top of native BigInt.
It can be compiled using https://www.npmjs.com/package/babel-plugin-transform-bigint to use JSBI.

# Usage:

## Installation:
`npm install @yaffle/bigdecimal`

## Type conversion:

`BigDecimal.BigDecimal(string)`
Expand Down Expand Up @@ -54,6 +59,17 @@ a polyfill for decimal propocal - https://github.com/tc39/proposal-decimal

The `rounding` argument may look like `{maximumFractionDigits: 10, roundingMode: "half-even"}` or `{maximumSignificantDigits: 10, roundingMode: "half-even"}`, where the roundingMode can be "floor", or "ceil", or "half-even", or "half-up".

## Example:
```javascript

import BigDecimal from './node_modules/@yaffle/bigdecimal/BigDecimal.js';

var pi = BigDecimal.multiply(BigDecimal.BigDecimal(4), BigDecimal.atan(BigDecimal.BigDecimal(1), {maximumSignificantDigits: 1000, roundingMode: 'half-even'}));

console.log(pi.toString());

```

# Similar projects:
1. https://github.com/MikeMcl/decimal.js/
2. https://github.com/uzyn/bigdenary
Expand Down
8 changes: 6 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@yaffle/bigdecimal",
"version": "1.0.0",
"version": "1.0.2",
"description": "Arbitrary precision decimal arithmetic library. Polyfill for decimal proposal. Implemented on the top of BigInt.",
"main": "BigDecimal.js",
"scripts": {
Expand All @@ -17,10 +17,14 @@
"arithmetic",
"bigdecimal"
],
"files": [
"BigDecimal.js"
],
"author": "Viktor Mukhachev",
"license": "ISC",
"bugs": {
"url": "https://github.com/Yaffle/BigDecimal/issues"
},
"homepage": "https://github.com/Yaffle/BigDecimal#readme"
"homepage": "https://github.com/Yaffle/BigDecimal#readme",
"type": "module"
}

0 comments on commit 051f8d3

Please sign in to comment.