initial commit
This commit is contained in:
15
node_modules/almost-equal/.npmignore
generated
vendored
Normal file
15
node_modules/almost-equal/.npmignore
generated
vendored
Normal file
@@ -0,0 +1,15 @@
|
||||
lib-cov
|
||||
*.seed
|
||||
*.log
|
||||
*.csv
|
||||
*.dat
|
||||
*.out
|
||||
*.pid
|
||||
*.gz
|
||||
|
||||
pids
|
||||
logs
|
||||
results
|
||||
|
||||
npm-debug.log
|
||||
node_modules/*
|
||||
22
node_modules/almost-equal/LICENSE
generated
vendored
Normal file
22
node_modules/almost-equal/LICENSE
generated
vendored
Normal file
@@ -0,0 +1,22 @@
|
||||
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) 2013 Mikola Lysenko
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
47
node_modules/almost-equal/README.md
generated
vendored
Normal file
47
node_modules/almost-equal/README.md
generated
vendored
Normal file
@@ -0,0 +1,47 @@
|
||||
almost-equal
|
||||
============
|
||||
Checks when two floats are almost equal.
|
||||
|
||||
Use
|
||||
===
|
||||
First install using npm:
|
||||
|
||||
npm install almost-equal
|
||||
|
||||
Then use as follows:
|
||||
|
||||
```javascript
|
||||
var almostEqual = require("almost-equal")
|
||||
|
||||
var a = 100
|
||||
, b = 100 + 1e-12
|
||||
|
||||
//Check if a == b up to float precision
|
||||
console.log(almostEqual(a, b, almostEqual.FLT_EPSILON, almostEqual.FLT_EPSILON))
|
||||
|
||||
//Check if a == b up to double precision
|
||||
console.log(almostEqual(a, b, almostEqual.DBL_EPSILON, almostEqual.DBL_EPSILON))
|
||||
```
|
||||
|
||||
### `almostEqual(a, b[, absoluteTolerance [, relativeTolerance]])`
|
||||
Checks if two floats are within the given tolerances of one another using the formula:
|
||||
|
||||
|a - b| < max(absoluteTolerance, min(|a|, |b|) * relativeTolerance)
|
||||
|
||||
* `a` and `b` are the two numbers to comapre
|
||||
* `absoluteTolerance` is a fixed minimal tolerance (set to 0 to ignore)
|
||||
* `relativeTolerance` is a tolerance that scales with a/b (set to 0 to ignore)
|
||||
|
||||
**Returns** `true` if `a` and `b` are approximately equal.
|
||||
|
||||
If tolerance argument is omitted, `almostEqual.DBL_EPSILON` value is used by default.
|
||||
|
||||
### `almostEqual.FLT_EPSILON`
|
||||
Floating point (32-bit) epsilon
|
||||
|
||||
### `almostEqual.DBL_EPSILON`
|
||||
Double precision (64-bit) epsilon
|
||||
|
||||
Credits
|
||||
=======
|
||||
(c) 2013 Mikola Lysenko. MIT License
|
||||
24
node_modules/almost-equal/almost_equal.js
generated
vendored
Normal file
24
node_modules/almost-equal/almost_equal.js
generated
vendored
Normal file
@@ -0,0 +1,24 @@
|
||||
"use strict"
|
||||
|
||||
var abs = Math.abs
|
||||
, min = Math.min
|
||||
|
||||
function almostEqual(a, b, absoluteError, relativeError) {
|
||||
var d = abs(a - b)
|
||||
|
||||
if (absoluteError == null) absoluteError = almostEqual.DBL_EPSILON;
|
||||
if (relativeError == null) relativeError = absoluteError;
|
||||
|
||||
if(d <= absoluteError) {
|
||||
return true
|
||||
}
|
||||
if(d <= relativeError * min(abs(a), abs(b))) {
|
||||
return true
|
||||
}
|
||||
return a === b
|
||||
}
|
||||
|
||||
almostEqual.FLT_EPSILON = 1.19209290e-7
|
||||
almostEqual.DBL_EPSILON = 2.2204460492503131e-16
|
||||
|
||||
module.exports = almostEqual
|
||||
37
node_modules/almost-equal/package.json
generated
vendored
Normal file
37
node_modules/almost-equal/package.json
generated
vendored
Normal file
@@ -0,0 +1,37 @@
|
||||
{
|
||||
"name": "almost-equal",
|
||||
"version": "1.1.0",
|
||||
"description": "Test if two floats are almost equal",
|
||||
"main": "almost_equal.js",
|
||||
"directories": {
|
||||
"test": "test"
|
||||
},
|
||||
"dependencies": {},
|
||||
"devDependencies": {
|
||||
"tap": "~0.4.1"
|
||||
},
|
||||
"scripts": {
|
||||
"test": "tap test/*.js"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git://github.com/mikolalysenko/almost-equal.git"
|
||||
},
|
||||
"keywords": [
|
||||
"float",
|
||||
"compare",
|
||||
"double",
|
||||
"round",
|
||||
"equal",
|
||||
"almost",
|
||||
"near",
|
||||
"tolerance",
|
||||
"epsilon",
|
||||
"FLT_EPSILON",
|
||||
"DBL_EPSILON"
|
||||
],
|
||||
"author": "Mikola Lysenko",
|
||||
"license": "MIT",
|
||||
"readmeFilename": "README.md",
|
||||
"gitHead": "bb9919030f650a6b1b5a9f0f65c406055146d259"
|
||||
}
|
||||
15
node_modules/almost-equal/test/test.js
generated
vendored
Normal file
15
node_modules/almost-equal/test/test.js
generated
vendored
Normal file
@@ -0,0 +1,15 @@
|
||||
var almostEqual = require("../almost_equal.js")
|
||||
|
||||
require("tap").test("almost-equal", function(t) {
|
||||
|
||||
var a = 100
|
||||
, b = 100 + 1e-12
|
||||
|
||||
//Check if a == b up to float precision
|
||||
t.assert(almostEqual(a, b, almostEqual.FLT_EPSILON, almostEqual.FLT_EPSILON))
|
||||
|
||||
//Check if a == b up to double precision
|
||||
t.assert(!almostEqual(a, b, almostEqual.DBL_EPSILON, almostEqual.DBL_EPSILON))
|
||||
|
||||
t.end()
|
||||
})
|
||||
Reference in New Issue
Block a user