Skip to content

Instantly share code, notes, and snippets.

@mauriciopoppe
Created April 9, 2016 03:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mauriciopoppe/ee0482290bcbbc28050be428a14c61c1 to your computer and use it in GitHub Desktop.
Save mauriciopoppe/ee0482290bcbbc28050be428a14c61c1 to your computer and use it in GitHub Desktop.
esnextbin sketch
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>ESNextbin Sketch</title>
<!-- put additional styles and scripts here -->
</head>
<body>
<!-- put markup and other contents here -->
</body>
</html>
import nextAfter from 'nextafter'
import Interval from 'interval-arithmetic'
const prev = (v) => nextAfter(v, -Infinity)
const next = (v) => nextAfter(v, Infinity)
// [2, 3]
console.log( Interval(2, 3) )
// (2, 3]
console.log( Interval(next(2), 3) )
// [2, 3)
console.log( Interval(2, prev(3)) )
// (2, 3)
console.log( Interval(next(2), prev(3)) )
{
"name": "esnextbin-sketch",
"version": "0.0.0",
"dependencies": {
"nextafter": "1.0.0",
"interval-arithmetic": "0.6.3"
}
}
'use strict';
var _nextafter = require('nextafter');
var _nextafter2 = _interopRequireDefault(_nextafter);
var _intervalArithmetic = require('interval-arithmetic');
var _intervalArithmetic2 = _interopRequireDefault(_intervalArithmetic);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
var prev = function prev(v) {
return (0, _nextafter2.default)(v, -Infinity);
};
var next = function next(v) {
return (0, _nextafter2.default)(v, Infinity);
};
// [2, 3]
console.log((0, _intervalArithmetic2.default)(2, 3));
// (2, 3]
console.log((0, _intervalArithmetic2.default)(next(2), 3));
// [2, 3)
console.log((0, _intervalArithmetic2.default)(2, prev(3)));
// (2, 3)
console.log((0, _intervalArithmetic2.default)(next(2), prev(3)));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment