An open API service indexing awesome lists of open source software.

https://github.com/bendrucker/round.js

Round numbers to the nearest multiple with an optional direction
https://github.com/bendrucker/round.js

Last synced: 5 months ago
JSON representation

Round numbers to the nearest multiple with an optional direction

Awesome Lists containing this project

README

          

round.js [![Build Status](https://travis-ci.org/bendrucker/round.js.svg?branch=master)](https://travis-ci.org/bendrucker/round.js) [![Greenkeeper badge](https://badges.greenkeeper.io/bendrucker/round.js.svg)](https://greenkeeper.io/)
========

> Round numbers to the nearest multiple with an optional direction.

## Installing

```js
$ npm install --save round
```

## API

#### `round(value, [multiple], [direction])` -> `number`

##### value

*Required*
Type: `number`

The value to round.

##### multiple

Type: `number`
Default: `1`

The multiple to round to.

##### direction

Type: `string`
Values: `up` / `down`

If no direction is supplied, the number will be rounded to the nearest direction, defaulting to up if the value is equidistant from the rounded values.

#### `round.down(value, multiple)` -> `number`

Convenience method for rounding down.

#### `round.up(value, multiple)` -> `number`

Convenience method for rounding up.