https://github.com/jcoreio/ulp
Math.nextAfter, Math.nextDown, Math.nextUp, Math.ulp in javascript
https://github.com/jcoreio/ulp
Last synced: 11 months ago
JSON representation
Math.nextAfter, Math.nextDown, Math.nextUp, Math.ulp in javascript
- Host: GitHub
- URL: https://github.com/jcoreio/ulp
- Owner: jcoreio
- License: mit
- Created: 2017-02-02T22:37:37.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2017-10-07T21:41:22.000Z (over 8 years ago)
- Last Synced: 2024-11-09T14:50:22.295Z (over 1 year ago)
- Language: JavaScript
- Homepage:
- Size: 96.7 KB
- Stars: 5
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.md
Awesome Lists containing this project
README
# ulp
[](https://travis-ci.org/jcoreio/ulp)
[](https://coveralls.io/github/jcoreio/ulp?branch=master)
[](https://github.com/semantic-release/semantic-release)
[](http://commitizen.github.io/cz-cli/)
Math.nextDown, Math.nextUp, Math.ulp in javascript (from https://gist.github.com/Yaffle/4654250)
## `nextUp(x: number): number`
Returns the smallest floating-point number greater than `x`.
**Denormalized values may not be supported.**
```js
var nextUp = require('ulp').nextUp
nextUp(1) // 1.0000000000000002
```
## `nextDown(x: number): number`
Returns the largest floating-point number less than `x`.
**Denormalized values may not be supported.**
```js
var nextDown = require('ulp').nextDown
nextDown(1) // 0.9999999999999999
```
## `ulp(x: number): number`
Returns the unit in the last place of `x`.
**Denormalized values may not be supported.**
```js
var ulp = require('ulp').ulp
ulp(1) // 1.1102230246251565e-16
```
## `monkeypatch(): void`
Monkeypatches `nextUp`, `nextDown`, and `ulp` onto `Math`.
```js
require('ulp').monkeypatch()
Math.nextUp(1) // 1.0000000000000002
Math.nextDown(1) // 0.9999999999999999
Math.ulp(1) // 1.1102230246251565e-16
```