@stdlib/number-float32-base-assert 0.2.2 → 0.3.1

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 CHANGED
@@ -1 +1 @@
1
- Copyright (c) 2016-2024 The Stdlib Authors.
1
+ Copyright (c) 2016-2026 The Stdlib Authors.
package/README.md CHANGED
@@ -68,8 +68,10 @@ The namespace contains the following functions:
68
68
 
69
69
  <div class="namespace-toc">
70
70
 
71
- - <span class="signature">[`isSameValueZerof( a, b )`][@stdlib/number/float32/base/assert/is-same-value-zero]</span><span class="delimiter">: </span><span class="description">test if two single-precision floating-point numbers are the same value.</span>
72
- - <span class="signature">[`isSameValuef( a, b )`][@stdlib/number/float32/base/assert/is-same-value]</span><span class="delimiter">: </span><span class="description">test if two single-precision floating-point numbers are the same value.</span>
71
+ - <span class="signature">[`isAlmostEqual( a, b, maxULP )`][@stdlib/number/float32/base/assert/is-almost-equal]</span><span class="delimiter">: </span><span class="description">test if two single-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/float32/base/assert/is-almost-same-value]</span><span class="delimiter">: </span><span class="description">test if two single-precision floating-point numbers are approximately the same value within a specified number of ULPs (units in the last place).</span>
73
+ - <span class="signature">[`isSameValueZero( a, b )`][@stdlib/number/float32/base/assert/is-same-value-zero]</span><span class="delimiter">: </span><span class="description">test if two single-precision floating-point numbers are the same value.</span>
74
+ - <span class="signature">[`isSameValue( a, b )`][@stdlib/number/float32/base/assert/is-same-value]</span><span class="delimiter">: </span><span class="description">test if two single-precision floating-point numbers are the same value.</span>
73
75
 
74
76
  </div>
75
77
 
@@ -140,7 +142,7 @@ See [LICENSE][stdlib-license].
140
142
 
141
143
  ## Copyright
142
144
 
143
- Copyright &copy; 2016-2024. The Stdlib [Authors][stdlib-authors].
145
+ Copyright &copy; 2016-2026. The Stdlib [Authors][stdlib-authors].
144
146
 
145
147
  </section>
146
148
 
@@ -153,8 +155,8 @@ Copyright &copy; 2016-2024. The Stdlib [Authors][stdlib-authors].
153
155
  [npm-image]: http://img.shields.io/npm/v/@stdlib/number-float32-base-assert.svg
154
156
  [npm-url]: https://npmjs.org/package/@stdlib/number-float32-base-assert
155
157
 
156
- [test-image]: https://github.com/stdlib-js/number-float32-base-assert/actions/workflows/test.yml/badge.svg?branch=v0.2.2
157
- [test-url]: https://github.com/stdlib-js/number-float32-base-assert/actions/workflows/test.yml?query=branch:v0.2.2
158
+ [test-image]: https://github.com/stdlib-js/number-float32-base-assert/actions/workflows/test.yml/badge.svg?branch=v0.3.1
159
+ [test-url]: https://github.com/stdlib-js/number-float32-base-assert/actions/workflows/test.yml?query=branch:v0.3.1
158
160
 
159
161
  [coverage-image]: https://img.shields.io/codecov/c/github/stdlib-js/number-float32-base-assert/main.svg
160
162
  [coverage-url]: https://codecov.io/github/stdlib-js/number-float32-base-assert?branch=main
@@ -166,8 +168,8 @@ Copyright &copy; 2016-2024. The Stdlib [Authors][stdlib-authors].
166
168
 
167
169
  -->
168
170
 
169
- [chat-image]: https://img.shields.io/gitter/room/stdlib-js/stdlib.svg
170
- [chat-url]: https://app.gitter.im/#/room/#stdlib-js_stdlib:gitter.im
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 &copy; 2016-2024. The Stdlib [Authors][stdlib-authors].
188
190
 
189
191
  <!-- <toc-links> -->
190
192
 
193
+ [@stdlib/number/float32/base/assert/is-almost-equal]: https://www.npmjs.com/package/@stdlib/number-float32-base-assert-is-almost-equal
194
+
195
+ [@stdlib/number/float32/base/assert/is-almost-same-value]: https://www.npmjs.com/package/@stdlib/number-float32-base-assert-is-almost-same-value
196
+
191
197
  [@stdlib/number/float32/base/assert/is-same-value-zero]: https://www.npmjs.com/package/@stdlib/number-float32-base-assert-is-same-value-zero
192
198
 
193
199
  [@stdlib/number/float32/base/assert/is-same-value]: https://www.npmjs.com/package/@stdlib/number-float32-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,"isSameValuef",require('@stdlib/number-float32-base-assert-is-same-value/dist'));r(e,"isSameValueZerof",require('@stdlib/number-float32-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-float32-base-assert-is-almost-equal/dist'));r(e,"isAlmostSameValue",require('@stdlib/number-float32-base-assert-is-almost-same-value/dist'));r(e,"isSameValue",require('@stdlib/number-float32-base-assert-is-same-value/dist'));r(e,"isSameValueZero",require('@stdlib/number-float32-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 isSameValuef\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/number/float32/base/assert/is-same-value}\n*/\nsetReadOnly( ns, 'isSameValuef', require( '@stdlib/number-float32-base-assert-is-same-value' ) );\n\n/**\n* @name isSameValueZerof\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/number/float32/base/assert/is-same-value-zero}\n*/\nsetReadOnly( ns, 'isSameValueZerof', require( '@stdlib/number-float32-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,eAAgB,QAAS,kDAAmD,CAAE,EAS/FD,EAAaC,EAAI,mBAAoB,QAAS,uDAAwD,CAAE,EAKxG,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/float32/base/assert/is-almost-equal}\n*/\nsetReadOnly( ns, 'isAlmostEqual', require( '@stdlib/number-float32-base-assert-is-almost-equal' ) );\n\n/**\n* @name isAlmostSameValue\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/number/float32/base/assert/is-almost-same-value}\n*/\nsetReadOnly( ns, 'isAlmostSameValue', require( '@stdlib/number-float32-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/float32/base/assert/is-same-value}\n*/\nsetReadOnly( ns, 'isSameValue', require( '@stdlib/number-float32-base-assert-is-same-value' ) );\n\n/**\n* @name isSameValueZero\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/number/float32/base/assert/is-same-value-zero}\n*/\nsetReadOnly( ns, 'isSameValueZero', require( '@stdlib/number-float32-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
  }
@@ -20,13 +20,92 @@
20
20
 
21
21
  /* eslint-disable max-lines */
22
22
 
23
- import isSameValuef = require( '@stdlib/number-float32-base-assert-is-same-value' );
24
- import isSameValueZerof = require( '@stdlib/number-float32-base-assert-is-same-value-zero' );
23
+ import isAlmostEqual = require( '@stdlib/number-float32-base-assert-is-almost-equal' );
24
+ import isAlmostSameValue = require( '@stdlib/number-float32-base-assert-is-almost-same-value' );
25
+ import isSameValue = require( '@stdlib/number-float32-base-assert-is-same-value' );
26
+ import isSameValueZero = require( '@stdlib/number-float32-base-assert-is-same-value-zero' );
25
27
 
26
28
  /**
27
29
  * Interface describing the `assert` namespace.
28
30
  */
29
31
  interface Namespace {
32
+ /**
33
+ * Tests if two single-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 single-precision floating-point numbers are approximately equal within a specified number of ULPs
44
+ *
45
+ * @example
46
+ * var EPS = require( '@stdlib/constants-float32-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 single-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 single-precision floating-point numbers are approximately the same value within a specified number of ULPs
82
+ *
83
+ * @example
84
+ * var EPS = require( '@stdlib/constants-float32-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 single-precision floating-point numbers are the same value.
32
111
  *
@@ -41,28 +120,28 @@ interface Namespace {
41
120
  * @example
42
121
  * var toFloat32 = require( '@stdlib/number-float64-base-to-float32' );
43
122
  *
44
- * var bool = ns.isSameValuef( toFloat32( 3.14 ), toFloat32( 3.14 ) );
123
+ * var bool = ns.isSameValue( toFloat32( 3.14 ), toFloat32( 3.14 ) );
45
124
  * // returns true
46
125
  *
47
126
  * @example
48
127
  * var toFloat32 = require( '@stdlib/number-float64-base-to-float32' );
49
128
  *
50
- * var bool = ns.isSameValuef( toFloat32( -0.0 ), toFloat32( -0.0 ) );
129
+ * var bool = ns.isSameValue( toFloat32( -0.0 ), toFloat32( -0.0 ) );
51
130
  * // returns true
52
131
  *
53
132
  * @example
54
133
  * var toFloat32 = require( '@stdlib/number-float64-base-to-float32' );
55
134
  *
56
- * var bool = ns.isSameValuef( toFloat32( -0.0 ), toFloat32( 0.0 ) );
135
+ * var bool = ns.isSameValue( toFloat32( -0.0 ), toFloat32( 0.0 ) );
57
136
  * // returns false
58
137
  *
59
138
  * @example
60
139
  * var toFloat32 = require( '@stdlib/number-float64-base-to-float32' );
61
140
  *
62
- * var bool = ns.isSameValuef( toFloat32( NaN ), toFloat32( NaN ) );
141
+ * var bool = ns.isSameValue( toFloat32( NaN ), toFloat32( NaN ) );
63
142
  * // returns true
64
143
  */
65
- isSameValuef: typeof isSameValuef;
144
+ isSameValue: typeof isSameValue;
66
145
 
67
146
  /**
68
147
  * Tests if two single-precision floating-point numbers are the same value.
@@ -78,32 +157,32 @@ interface Namespace {
78
157
  * @example
79
158
  * var toFloat32 = require( '@stdlib/number-float64-base-to-float32' );
80
159
  *
81
- * var bool = ns.isSameValueZerof( toFloat32( 3.14 ), toFloat32( 3.14 ) );
160
+ * var bool = ns.isSameValueZero( toFloat32( 3.14 ), toFloat32( 3.14 ) );
82
161
  * // returns true
83
162
  *
84
163
  * @example
85
164
  * var toFloat32 = require( '@stdlib/number-float64-base-to-float32' );
86
165
  *
87
- * var bool = ns.isSameValueZerof( toFloat32( -0.0 ), toFloat32( -0.0 ) );
166
+ * var bool = ns.isSameValueZero( toFloat32( -0.0 ), toFloat32( -0.0 ) );
88
167
  * // returns true
89
168
  *
90
169
  * @example
91
170
  * var toFloat32 = require( '@stdlib/number-float64-base-to-float32' );
92
171
  *
93
- * var bool = ns.isSameValueZerof( toFloat32( -0.0 ), toFloat32( 0.0 ) );
172
+ * var bool = ns.isSameValueZero( toFloat32( -0.0 ), toFloat32( 0.0 ) );
94
173
  * // returns true
95
174
  *
96
175
  * @example
97
176
  * var toFloat32 = require( '@stdlib/number-float64-base-to-float32' );
98
177
  *
99
- * var bool = ns.isSameValueZerof( toFloat32( NaN ), toFloat32( NaN ) );
178
+ * var bool = ns.isSameValueZero( toFloat32( NaN ), toFloat32( NaN ) );
100
179
  * // returns true
101
180
  */
102
- isSameValueZerof: typeof isSameValueZerof;
181
+ isSameValueZero: typeof isSameValueZero;
103
182
  }
104
183
 
105
184
  /**
106
- * Base double-precision floating-point number assert functions.
185
+ * Base single-precision floating-point number assert functions.
107
186
  */
108
187
  declare var ns: Namespace;
109
188
 
package/lib/index.js CHANGED
@@ -37,22 +37,40 @@ var setReadOnly = require( '@stdlib/utils-define-read-only-property' );
37
37
  var ns = {};
38
38
 
39
39
  /**
40
- * @name isSameValuef
40
+ * @name isAlmostEqual
41
+ * @memberof ns
42
+ * @readonly
43
+ * @type {Function}
44
+ * @see {@link module:@stdlib/number/float32/base/assert/is-almost-equal}
45
+ */
46
+ setReadOnly( ns, 'isAlmostEqual', require( '@stdlib/number-float32-base-assert-is-almost-equal' ) );
47
+
48
+ /**
49
+ * @name isAlmostSameValue
50
+ * @memberof ns
51
+ * @readonly
52
+ * @type {Function}
53
+ * @see {@link module:@stdlib/number/float32/base/assert/is-almost-same-value}
54
+ */
55
+ setReadOnly( ns, 'isAlmostSameValue', require( '@stdlib/number-float32-base-assert-is-almost-same-value' ) );
56
+
57
+ /**
58
+ * @name isSameValue
41
59
  * @memberof ns
42
60
  * @readonly
43
61
  * @type {Function}
44
62
  * @see {@link module:@stdlib/number/float32/base/assert/is-same-value}
45
63
  */
46
- setReadOnly( ns, 'isSameValuef', require( '@stdlib/number-float32-base-assert-is-same-value' ) );
64
+ setReadOnly( ns, 'isSameValue', require( '@stdlib/number-float32-base-assert-is-same-value' ) );
47
65
 
48
66
  /**
49
- * @name isSameValueZerof
67
+ * @name isSameValueZero
50
68
  * @memberof ns
51
69
  * @readonly
52
70
  * @type {Function}
53
71
  * @see {@link module:@stdlib/number/float32/base/assert/is-same-value-zero}
54
72
  */
55
- setReadOnly( ns, 'isSameValueZerof', require( '@stdlib/number-float32-base-assert-is-same-value-zero' ) );
73
+ setReadOnly( ns, 'isSameValueZero', require( '@stdlib/number-float32-base-assert-is-same-value-zero' ) );
56
74
 
57
75
 
58
76
  // EXPORTS //
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@stdlib/number-float32-base-assert",
3
- "version": "0.2.2",
4
- "description": "Base double-precision floating-point number assert functions.",
3
+ "version": "0.3.1",
4
+ "description": "Base single-precision floating-point number assert functions.",
5
5
  "license": "Apache-2.0",
6
6
  "author": {
7
7
  "name": "The Stdlib Authors",
@@ -30,9 +30,11 @@
30
30
  "url": "https://github.com/stdlib-js/stdlib/issues"
31
31
  },
32
32
  "dependencies": {
33
- "@stdlib/number-float32-base-assert-is-same-value": "^0.2.2",
34
- "@stdlib/number-float32-base-assert-is-same-value-zero": "^0.2.1",
35
- "@stdlib/utils-define-read-only-property": "^0.2.2"
33
+ "@stdlib/number-float32-base-assert-is-almost-equal": "^0.1.0",
34
+ "@stdlib/number-float32-base-assert-is-almost-same-value": "^0.1.0",
35
+ "@stdlib/number-float32-base-assert-is-same-value": "^0.2.3",
36
+ "@stdlib/number-float32-base-assert-is-same-value-zero": "^0.2.2",
37
+ "@stdlib/utils-define-read-only-property": "^0.2.3"
36
38
  },
37
39
  "devDependencies": {},
38
40
  "engines": {