@stdlib/number-float64-base-assert 0.2.1 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/NOTICE +1 -1
- package/README.md +11 -5
- package/dist/index.js +1 -1
- package/dist/index.js.map +2 -2
- package/docs/types/index.d.ts +80 -1
- package/lib/index.js +18 -0
- package/package.json +4 -2
package/NOTICE
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
Copyright (c) 2016-
|
|
1
|
+
Copyright (c) 2016-2026 The Stdlib Authors.
|
package/README.md
CHANGED
|
@@ -68,6 +68,8 @@ The namespace contains the following functions:
|
|
|
68
68
|
|
|
69
69
|
<div class="namespace-toc">
|
|
70
70
|
|
|
71
|
+
- <span class="signature">[`isAlmostEqual( a, b, maxULP )`][@stdlib/number/float64/base/assert/is-almost-equal]</span><span class="delimiter">: </span><span class="description">test if two double-precision floating-point numbers are approximately equal within a specified number of ULPs (units in the last place).</span>
|
|
72
|
+
- <span class="signature">[`isAlmostSameValue( a, b, maxULP )`][@stdlib/number/float64/base/assert/is-almost-same-value]</span><span class="delimiter">: </span><span class="description">test if two double-precision floating-point numbers are approximately the same value within a specified number of ULPs (units in the last place).</span>
|
|
71
73
|
- <span class="signature">[`isSameValueZero( a, b )`][@stdlib/number/float64/base/assert/is-same-value-zero]</span><span class="delimiter">: </span><span class="description">test if two double-precision floating-point numbers are the same value.</span>
|
|
72
74
|
- <span class="signature">[`isSameValue( a, b )`][@stdlib/number/float64/base/assert/is-same-value]</span><span class="delimiter">: </span><span class="description">test if two double-precision floating-point numbers are the same value.</span>
|
|
73
75
|
|
|
@@ -140,7 +142,7 @@ See [LICENSE][stdlib-license].
|
|
|
140
142
|
|
|
141
143
|
## Copyright
|
|
142
144
|
|
|
143
|
-
Copyright © 2016-
|
|
145
|
+
Copyright © 2016-2026. The Stdlib [Authors][stdlib-authors].
|
|
144
146
|
|
|
145
147
|
</section>
|
|
146
148
|
|
|
@@ -153,8 +155,8 @@ Copyright © 2016-2024. The Stdlib [Authors][stdlib-authors].
|
|
|
153
155
|
[npm-image]: http://img.shields.io/npm/v/@stdlib/number-float64-base-assert.svg
|
|
154
156
|
[npm-url]: https://npmjs.org/package/@stdlib/number-float64-base-assert
|
|
155
157
|
|
|
156
|
-
[test-image]: https://github.com/stdlib-js/number-float64-base-assert/actions/workflows/test.yml/badge.svg?branch=v0.
|
|
157
|
-
[test-url]: https://github.com/stdlib-js/number-float64-base-assert/actions/workflows/test.yml?query=branch:v0.
|
|
158
|
+
[test-image]: https://github.com/stdlib-js/number-float64-base-assert/actions/workflows/test.yml/badge.svg?branch=v0.3.0
|
|
159
|
+
[test-url]: https://github.com/stdlib-js/number-float64-base-assert/actions/workflows/test.yml?query=branch:v0.3.0
|
|
158
160
|
|
|
159
161
|
[coverage-image]: https://img.shields.io/codecov/c/github/stdlib-js/number-float64-base-assert/main.svg
|
|
160
162
|
[coverage-url]: https://codecov.io/github/stdlib-js/number-float64-base-assert?branch=main
|
|
@@ -166,8 +168,8 @@ Copyright © 2016-2024. The Stdlib [Authors][stdlib-authors].
|
|
|
166
168
|
|
|
167
169
|
-->
|
|
168
170
|
|
|
169
|
-
[chat-image]: https://img.shields.io/
|
|
170
|
-
[chat-url]: https://
|
|
171
|
+
[chat-image]: https://img.shields.io/badge/zulip-join_chat-brightgreen.svg
|
|
172
|
+
[chat-url]: https://stdlib.zulipchat.com
|
|
171
173
|
|
|
172
174
|
[stdlib]: https://github.com/stdlib-js/stdlib
|
|
173
175
|
|
|
@@ -188,6 +190,10 @@ Copyright © 2016-2024. The Stdlib [Authors][stdlib-authors].
|
|
|
188
190
|
|
|
189
191
|
<!-- <toc-links> -->
|
|
190
192
|
|
|
193
|
+
[@stdlib/number/float64/base/assert/is-almost-equal]: https://www.npmjs.com/package/@stdlib/number-float64-base-assert-is-almost-equal
|
|
194
|
+
|
|
195
|
+
[@stdlib/number/float64/base/assert/is-almost-same-value]: https://www.npmjs.com/package/@stdlib/number-float64-base-assert-is-almost-same-value
|
|
196
|
+
|
|
191
197
|
[@stdlib/number/float64/base/assert/is-same-value-zero]: https://www.npmjs.com/package/@stdlib/number-float64-base-assert-is-same-value-zero
|
|
192
198
|
|
|
193
199
|
[@stdlib/number/float64/base/assert/is-same-value]: https://www.npmjs.com/package/@stdlib/number-float64-base-assert-is-same-value
|
package/dist/index.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
"use strict";var r=require('@stdlib/utils-define-read-only-property/dist'),e={};r(e,"isSameValue",require('@stdlib/number-float64-base-assert-is-same-value/dist'));r(e,"isSameValueZero",require('@stdlib/number-float64-base-assert-is-same-value-zero/dist'));module.exports=e;
|
|
1
|
+
"use strict";var r=require('@stdlib/utils-define-read-only-property/dist'),e={};r(e,"isAlmostEqual",require('@stdlib/number-float64-base-assert-is-almost-equal/dist'));r(e,"isAlmostSameValue",require('@stdlib/number-float64-base-assert-is-almost-same-value/dist'));r(e,"isSameValue",require('@stdlib/number-float64-base-assert-is-same-value/dist'));r(e,"isSameValueZero",require('@stdlib/number-float64-base-assert-is-same-value-zero/dist'));module.exports=e;
|
|
2
2
|
/** @license Apache-2.0 */
|
|
3
3
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../lib/index.js"],
|
|
4
|
-
"sourcesContent": ["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2024 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/*\n* When adding modules to the namespace, ensure that they are added in alphabetical order according to module name.\n*/\n\n// MODULES //\n\nvar setReadOnly = require( '@stdlib/utils-define-read-only-property' );\n\n\n// MAIN //\n\n/**\n* Top-level namespace.\n*\n* @namespace ns\n*/\nvar ns = {};\n\n/**\n* @name isSameValue\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/number/float64/base/assert/is-same-value}\n*/\nsetReadOnly( ns, 'isSameValue', require( '@stdlib/number-float64-base-assert-is-same-value' ) );\n\n/**\n* @name isSameValueZero\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/number/float64/base/assert/is-same-value-zero}\n*/\nsetReadOnly( ns, 'isSameValueZero', require( '@stdlib/number-float64-base-assert-is-same-value-zero' ) );\n\n\n// EXPORTS //\n\nmodule.exports = ns;\n"],
|
|
5
|
-
"mappings": "aA0BA,IAAIA,EAAc,QAAS,yCAA0C,EAUjEC,EAAK,CAAC,EASVD,EAAaC,EAAI,cAAe,QAAS,kDAAmD,CAAE,EAS9FD,EAAaC,EAAI,kBAAmB,QAAS,uDAAwD,CAAE,EAKvG,OAAO,QAAUA",
|
|
4
|
+
"sourcesContent": ["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2024 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/*\n* When adding modules to the namespace, ensure that they are added in alphabetical order according to module name.\n*/\n\n// MODULES //\n\nvar setReadOnly = require( '@stdlib/utils-define-read-only-property' );\n\n\n// MAIN //\n\n/**\n* Top-level namespace.\n*\n* @namespace ns\n*/\nvar ns = {};\n\n/**\n* @name isAlmostEqual\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/number/float64/base/assert/is-almost-equal}\n*/\nsetReadOnly( ns, 'isAlmostEqual', require( '@stdlib/number-float64-base-assert-is-almost-equal' ) );\n\n/**\n* @name isAlmostSameValue\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/number/float64/base/assert/is-almost-same-value}\n*/\nsetReadOnly( ns, 'isAlmostSameValue', require( '@stdlib/number-float64-base-assert-is-almost-same-value' ) );\n\n/**\n* @name isSameValue\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/number/float64/base/assert/is-same-value}\n*/\nsetReadOnly( ns, 'isSameValue', require( '@stdlib/number-float64-base-assert-is-same-value' ) );\n\n/**\n* @name isSameValueZero\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/number/float64/base/assert/is-same-value-zero}\n*/\nsetReadOnly( ns, 'isSameValueZero', require( '@stdlib/number-float64-base-assert-is-same-value-zero' ) );\n\n\n// EXPORTS //\n\nmodule.exports = ns;\n"],
|
|
5
|
+
"mappings": "aA0BA,IAAIA,EAAc,QAAS,yCAA0C,EAUjEC,EAAK,CAAC,EASVD,EAAaC,EAAI,gBAAiB,QAAS,oDAAqD,CAAE,EASlGD,EAAaC,EAAI,oBAAqB,QAAS,yDAA0D,CAAE,EAS3GD,EAAaC,EAAI,cAAe,QAAS,kDAAmD,CAAE,EAS9FD,EAAaC,EAAI,kBAAmB,QAAS,uDAAwD,CAAE,EAKvG,OAAO,QAAUA",
|
|
6
6
|
"names": ["setReadOnly", "ns"]
|
|
7
7
|
}
|
package/docs/types/index.d.ts
CHANGED
|
@@ -20,6 +20,8 @@
|
|
|
20
20
|
|
|
21
21
|
/* eslint-disable max-lines */
|
|
22
22
|
|
|
23
|
+
import isAlmostEqual = require( '@stdlib/number-float64-base-assert-is-almost-equal' );
|
|
24
|
+
import isAlmostSameValue = require( '@stdlib/number-float64-base-assert-is-almost-same-value' );
|
|
23
25
|
import isSameValue = require( '@stdlib/number-float64-base-assert-is-same-value' );
|
|
24
26
|
import isSameValueZero = require( '@stdlib/number-float64-base-assert-is-same-value-zero' );
|
|
25
27
|
|
|
@@ -27,6 +29,83 @@ import isSameValueZero = require( '@stdlib/number-float64-base-assert-is-same-va
|
|
|
27
29
|
* Interface describing the `assert` namespace.
|
|
28
30
|
*/
|
|
29
31
|
interface Namespace {
|
|
32
|
+
/**
|
|
33
|
+
* Tests if two double-precision floating-point numbers are approximately equal within a specified number of ULPs (units in the last place).
|
|
34
|
+
*
|
|
35
|
+
* ## Notes
|
|
36
|
+
*
|
|
37
|
+
* - The function returns `false` if either input value is `NaN`.
|
|
38
|
+
* - The function does not distinguish between `-0` and `+0`, treating them as equal.
|
|
39
|
+
*
|
|
40
|
+
* @param a - first input value
|
|
41
|
+
* @param b - second input value
|
|
42
|
+
* @param maxULP - maximum allowed ULP difference
|
|
43
|
+
* @returns boolean indicating whether two double-precision floating-point numbers are approximately equal within a specified number of ULPs
|
|
44
|
+
*
|
|
45
|
+
* @example
|
|
46
|
+
* var EPS = require( '@stdlib/constants-float64-eps' );
|
|
47
|
+
*
|
|
48
|
+
* var bool = ns.isAlmostEqual( 1.0, 1.0+EPS, 1 );
|
|
49
|
+
* // returns true
|
|
50
|
+
*
|
|
51
|
+
* bool = ns.isAlmostEqual( 1.0+EPS, 1.0, 1 );
|
|
52
|
+
* // returns true
|
|
53
|
+
*
|
|
54
|
+
* bool = ns.isAlmostEqual( 1.0, 1.0+EPS+EPS, 1 );
|
|
55
|
+
* // returns false
|
|
56
|
+
*
|
|
57
|
+
* bool = ns.isAlmostEqual( 1.0, 1.0+EPS, 0 );
|
|
58
|
+
* // returns false
|
|
59
|
+
*
|
|
60
|
+
* bool = ns.isAlmostEqual( 0.0, -0.0, 0 );
|
|
61
|
+
* // returns true
|
|
62
|
+
*
|
|
63
|
+
* bool = ns.isAlmostEqual( 1.0, NaN, 1 );
|
|
64
|
+
* // returns false
|
|
65
|
+
*
|
|
66
|
+
* bool = ns.isAlmostEqual( NaN, NaN, 1 );
|
|
67
|
+
* // returns false
|
|
68
|
+
*/
|
|
69
|
+
isAlmostEqual: typeof isAlmostEqual;
|
|
70
|
+
|
|
71
|
+
/**
|
|
72
|
+
* Tests if two double-precision floating-point numbers are approximately the same value within a specified number of ULPs (units in the last place).
|
|
73
|
+
*
|
|
74
|
+
* ## Notes
|
|
75
|
+
*
|
|
76
|
+
* - The function differs from the `===` operator in that the function treats `-0` and `+0` as distinct and `NaNs` as the same.
|
|
77
|
+
*
|
|
78
|
+
* @param a - first input value
|
|
79
|
+
* @param b - second input value
|
|
80
|
+
* @param maxULP - maximum allowed ULP difference
|
|
81
|
+
* @returns boolean indicating whether two double-precision floating-point numbers are approximately the same value within a specified number of ULPs
|
|
82
|
+
*
|
|
83
|
+
* @example
|
|
84
|
+
* var EPS = require( '@stdlib/constants-float64-eps' );
|
|
85
|
+
*
|
|
86
|
+
* var bool = ns.isAlmostSameValue( 1.0, 1.0+EPS, 1 );
|
|
87
|
+
* // returns true
|
|
88
|
+
*
|
|
89
|
+
* bool = ns.isAlmostSameValue( 1.0+EPS, 1.0, 1 );
|
|
90
|
+
* // returns true
|
|
91
|
+
*
|
|
92
|
+
* bool = ns.isAlmostSameValue( 1.0, 1.0+EPS+EPS, 1 );
|
|
93
|
+
* // returns false
|
|
94
|
+
*
|
|
95
|
+
* bool = ns.isAlmostSameValue( 1.0, 1.0+EPS, 0 );
|
|
96
|
+
* // returns false
|
|
97
|
+
*
|
|
98
|
+
* bool = ns.isAlmostSameValue( 0.0, -0.0, 0 );
|
|
99
|
+
* // returns false
|
|
100
|
+
*
|
|
101
|
+
* bool = ns.isAlmostSameValue( 1.0, NaN, 1 );
|
|
102
|
+
* // returns false
|
|
103
|
+
*
|
|
104
|
+
* bool = ns.isAlmostSameValue( NaN, NaN, 1 );
|
|
105
|
+
* // returns true
|
|
106
|
+
*/
|
|
107
|
+
isAlmostSameValue: typeof isAlmostSameValue;
|
|
108
|
+
|
|
30
109
|
/**
|
|
31
110
|
* Tests if two double-precision floating-point numbers are the same value.
|
|
32
111
|
*
|
|
@@ -61,7 +140,7 @@ interface Namespace {
|
|
|
61
140
|
*
|
|
62
141
|
* ## Notes
|
|
63
142
|
*
|
|
64
|
-
* - The function differs from the `===` operator in that the function treats
|
|
143
|
+
* - The function differs from the `===` operator in that the function treats `NaNs` as the same value.
|
|
65
144
|
*
|
|
66
145
|
* @param a - first input value
|
|
67
146
|
* @param b - second input value
|
package/lib/index.js
CHANGED
|
@@ -36,6 +36,24 @@ var setReadOnly = require( '@stdlib/utils-define-read-only-property' );
|
|
|
36
36
|
*/
|
|
37
37
|
var ns = {};
|
|
38
38
|
|
|
39
|
+
/**
|
|
40
|
+
* @name isAlmostEqual
|
|
41
|
+
* @memberof ns
|
|
42
|
+
* @readonly
|
|
43
|
+
* @type {Function}
|
|
44
|
+
* @see {@link module:@stdlib/number/float64/base/assert/is-almost-equal}
|
|
45
|
+
*/
|
|
46
|
+
setReadOnly( ns, 'isAlmostEqual', require( '@stdlib/number-float64-base-assert-is-almost-equal' ) );
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* @name isAlmostSameValue
|
|
50
|
+
* @memberof ns
|
|
51
|
+
* @readonly
|
|
52
|
+
* @type {Function}
|
|
53
|
+
* @see {@link module:@stdlib/number/float64/base/assert/is-almost-same-value}
|
|
54
|
+
*/
|
|
55
|
+
setReadOnly( ns, 'isAlmostSameValue', require( '@stdlib/number-float64-base-assert-is-almost-same-value' ) );
|
|
56
|
+
|
|
39
57
|
/**
|
|
40
58
|
* @name isSameValue
|
|
41
59
|
* @memberof ns
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@stdlib/number-float64-base-assert",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.0",
|
|
4
4
|
"description": "Base double-precision floating-point number assert functions.",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"author": {
|
|
@@ -30,9 +30,11 @@
|
|
|
30
30
|
"url": "https://github.com/stdlib-js/stdlib/issues"
|
|
31
31
|
},
|
|
32
32
|
"dependencies": {
|
|
33
|
+
"@stdlib/number-float64-base-assert-is-almost-equal": "github:stdlib-js/number-float64-base-assert-is-almost-equal#main",
|
|
34
|
+
"@stdlib/number-float64-base-assert-is-almost-same-value": "github:stdlib-js/number-float64-base-assert-is-almost-same-value#main",
|
|
33
35
|
"@stdlib/number-float64-base-assert-is-same-value": "^0.2.1",
|
|
34
36
|
"@stdlib/number-float64-base-assert-is-same-value-zero": "^0.1.1",
|
|
35
|
-
"@stdlib/utils-define-read-only-property": "^0.2.
|
|
37
|
+
"@stdlib/utils-define-read-only-property": "^0.2.2"
|
|
36
38
|
},
|
|
37
39
|
"devDependencies": {},
|
|
38
40
|
"engines": {
|