Skip to content

Tevpro/round-half-even-ts

 
 

Repository files navigation

Round Half to Even

A utility for tie-breaking rounding, also called Banker's Rounding or Commercial Rounding.

Read more: https://en.wikipedia.org/wiki/Rounding#Round_half_to_even

Demo

https://tevpro.github.io/round-half-even-ts/

Installation

Using npm:

npm install --save round-half-even-ts

Or yarn:

yarn add round-half-even-ts

Usage

roundHalfEven(floatingPointValue, numberOfDecimals);

Node.js

import roundHalfEven from "round-half-even-ts";
roundHalfEven(1.435, 2); // returns 1.44

Within the browser:

<script src="https://unpkg.com/round-half-even-ts"></script>
<script>
  roundHalfEven(1.435, 2); // returns 1.44
</script>

Development

Make changes to src/index.js. Generate the browser-ready package:

npm run build

or

yarn build

Run tests:

npm test

or

yarn test

Releases

No releases published

Packages

No packages published

Languages

  • TypeScript 83.3%
  • JavaScript 16.7%