Skip to content

Commit 47d7548

Browse files
committed
feat: add constants/float16/fourth-root-eps
1 parent f0df313 commit 47d7548

File tree

8 files changed

+340
-0
lines changed

8 files changed

+340
-0
lines changed
Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
<!--
2+
3+
@license Apache-2.0
4+
5+
Copyright (c) 2025 The Stdlib Authors.
6+
7+
Licensed under the Apache License, Version 2.0 (the "License");
8+
you may not use this file except in compliance with the License.
9+
You may obtain a copy of the License at
10+
11+
http://www.apache.org/licenses/LICENSE-2.0
12+
13+
Unless required by applicable law or agreed to in writing, software
14+
distributed under the License is distributed on an "AS IS" BASIS,
15+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16+
See the License for the specific language governing permissions and
17+
limitations under the License.
18+
19+
-->
20+
21+
# FLOAT16_FOURTH_ROOT_EPS
22+
23+
> [Fourth root][nth-root] of [half-precision floating-point epsilon][@stdlib/constants/float16/eps].
24+
25+
<section class="usage">
26+
27+
## Usage
28+
29+
```javascript
30+
var FLOAT16_FOURTH_ROOT_EPS = require( '@stdlib/constants/float16/fourth-root-eps' );
31+
```
32+
33+
#### FLOAT16_FOURTH_ROOT_EPS
34+
35+
[Fourth root][nth-root] of [half-precision floating-point epsilon][@stdlib/constants/float16/eps].
36+
37+
```javascript
38+
var bool = ( FLOAT16_FOURTH_ROOT_EPS === 0.1767766952966369 );
39+
// returns true
40+
```
41+
42+
</section>
43+
44+
<!-- /.usage -->
45+
46+
<section class="examples">
47+
48+
## Examples
49+
50+
<!-- eslint no-undef: "error" -->
51+
52+
```javascript
53+
var FLOAT16_FOURTH_ROOT_EPS = require( '@stdlib/constants/float16/fourth-root-eps' );
54+
55+
var out = FLOAT16_FOURTH_ROOT_EPS;
56+
// returns 0.1767766952966369
57+
```
58+
59+
</section>
60+
61+
<!-- Section for related `stdlib` packages. Do not manually edit this section, as it is automatically populated. -->
62+
63+
<section class="related">
64+
65+
</section>
66+
67+
<!-- /.related -->
68+
69+
<!-- Section for all links. Make sure to keep an empty line after the `section` element and another before the `/section` close. -->
70+
71+
<section class="links">
72+
73+
[nth-root]: https://en.wikipedia.org/wiki/Nth_root
74+
75+
</section>
76+
77+
<!-- /.links -->
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
2+
{{alias}}
3+
Fourth root of half-precision floating-point epsilon.
4+
5+
Examples
6+
--------
7+
> {{alias}}
8+
0.1767766952966369
9+
10+
See Also
11+
--------
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
/*
2+
* @license Apache-2.0
3+
*
4+
* Copyright (c) 2025 The Stdlib Authors.
5+
*
6+
* Licensed under the Apache License, Version 2.0 (the "License");
7+
* you may not use this file except in compliance with the License.
8+
* You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing, software
13+
* distributed under the License is distributed on an "AS IS" BASIS,
14+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
* See the License for the specific language governing permissions and
16+
* limitations under the License.
17+
*/
18+
19+
// TypeScript Version: 4.1
20+
21+
/**
22+
* Fourth root of half-precision floating-point epsilon.
23+
*
24+
* @example
25+
* var eps = FLOAT16_FOURTH_ROOT_EPS;
26+
* // returns 0.1767766952966369
27+
*/
28+
declare const FLOAT16_FOURTH_ROOT_EPS: number;
29+
30+
31+
// EXPORTS //
32+
33+
export = FLOAT16_FOURTH_ROOT_EPS;
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
/*
2+
* @license Apache-2.0
3+
*
4+
* Copyright (c) 2025 The Stdlib Authors.
5+
*
6+
* Licensed under the Apache License, Version 2.0 (the "License");
7+
* you may not use this file except in compliance with the License.
8+
* You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing, software
13+
* distributed under the License is distributed on an "AS IS" BASIS,
14+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
* See the License for the specific language governing permissions and
16+
* limitations under the License.
17+
*/
18+
19+
import FLOAT16_FOURTH_ROOT_EPS = require( './index' );
20+
21+
22+
// TESTS //
23+
24+
// The export is a number...
25+
{
26+
// eslint-disable-next-line @typescript-eslint/no-unused-expressions
27+
FLOAT16_FOURTH_ROOT_EPS; // $ExpectType number
28+
}
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
/**
2+
* @license Apache-2.0
3+
*
4+
* Copyright (c) 2025 The Stdlib Authors.
5+
*
6+
* Licensed under the Apache License, Version 2.0 (the "License");
7+
* you may not use this file except in compliance with the License.
8+
* You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing, software
13+
* distributed under the License is distributed on an "AS IS" BASIS,
14+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
* See the License for the specific language governing permissions and
16+
* limitations under the License.
17+
*/
18+
19+
'use strict';
20+
21+
var FLOAT16_FOURTH_ROOT_EPS = require( './../lib' );
22+
23+
console.log( FLOAT16_FOURTH_ROOT_EPS );
24+
// => 0.1767766952966369
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
/**
2+
* @license Apache-2.0
3+
*
4+
* Copyright (c) 2025 The Stdlib Authors.
5+
*
6+
* Licensed under the Apache License, Version 2.0 (the "License");
7+
* you may not use this file except in compliance with the License.
8+
* You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing, software
13+
* distributed under the License is distributed on an "AS IS" BASIS,
14+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
* See the License for the specific language governing permissions and
16+
* limitations under the License.
17+
*/
18+
19+
'use strict';
20+
21+
/**
22+
* Fourth root of half-precision floating-point epsilon.
23+
*
24+
* @module @stdlib/constants/float16/fourth-root-eps
25+
* @type {number}
26+
*
27+
* @example
28+
* var FLOAT16_FOURTH_ROOT_EPS = require( '@stdlib/constants/float16/fourth-root-eps' );
29+
* // returns 0.1767766952966369
30+
*/
31+
32+
33+
// MAIN //
34+
35+
/**
36+
* Fourth root of half-precision floating-point epsilon.
37+
*
38+
* ```tex
39+
* \sqrt{\sqrt{\frac{1}{2^{10}}}}
40+
* ```
41+
*
42+
* @constant
43+
* @type {number}
44+
* @default 0.1767766952966369
45+
* @see [IEEE 754]{@link https://en.wikipedia.org/wiki/IEEE_754-1985}
46+
* @see [Half-precision floating-point format]{@link https://en.wikipedia.org/wiki/Half-precision_floating-point_format}
47+
*/
48+
var FLOAT16_FOURTH_ROOT_EPS = 0.1767766952966369;
49+
50+
51+
// EXPORTS //
52+
53+
module.exports = FLOAT16_FOURTH_ROOT_EPS;
Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
{
2+
"name": "@stdlib/constants/float16/fourth-root-eps",
3+
"version": "0.0.0",
4+
"description": "Fourth root of half-precision floating-point epsilon.",
5+
"license": "Apache-2.0",
6+
"author": {
7+
"name": "The Stdlib Authors",
8+
"url": "https://github.com/stdlib-js/stdlib/graphs/contributors"
9+
},
10+
"contributors": [
11+
{
12+
"name": "The Stdlib Authors",
13+
"url": "https://github.com/stdlib-js/stdlib/graphs/contributors"
14+
}
15+
],
16+
"main": "./lib",
17+
"directories": {
18+
"doc": "./docs",
19+
"example": "./examples",
20+
"include": "./include",
21+
"lib": "./lib",
22+
"test": "./test"
23+
},
24+
"types": "./docs/types",
25+
"scripts": {},
26+
"homepage": "https://github.com/stdlib-js/stdlib",
27+
"repository": {
28+
"type": "git",
29+
"url": "git://github.com/stdlib-js/stdlib.git"
30+
},
31+
"bugs": {
32+
"url": "https://github.com/stdlib-js/stdlib/issues"
33+
},
34+
"dependencies": {},
35+
"devDependencies": {},
36+
"engines": {
37+
"node": ">=0.10.0",
38+
"npm": ">2.7.0"
39+
},
40+
"os": [
41+
"aix",
42+
"darwin",
43+
"freebsd",
44+
"linux",
45+
"macos",
46+
"openbsd",
47+
"sunos",
48+
"win32",
49+
"windows"
50+
],
51+
"keywords": [
52+
"stdlib",
53+
"stdmath",
54+
"constant",
55+
"const",
56+
"mathematics",
57+
"math",
58+
"double",
59+
"dbl",
60+
"floating-point",
61+
"float",
62+
"float16",
63+
"16bit",
64+
"16-bit",
65+
"ieee754",
66+
"epsilon",
67+
"eps",
68+
"number",
69+
"sqrt",
70+
"fourth",
71+
"root"
72+
]
73+
}
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
/**
2+
* @license Apache-2.0
3+
*
4+
* Copyright (c) 2025 The Stdlib Authors.
5+
*
6+
* Licensed under the Apache License, Version 2.0 (the "License");
7+
* you may not use this file except in compliance with the License.
8+
* You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing, software
13+
* distributed under the License is distributed on an "AS IS" BASIS,
14+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
* See the License for the specific language governing permissions and
16+
* limitations under the License.
17+
*/
18+
19+
'use strict';
20+
21+
// MODULES //
22+
23+
var tape = require( 'tape' );
24+
var pow = require( '@stdlib/math/base/special/pow' );
25+
var sqrt = require( '@stdlib/math/base/special/sqrt' );
26+
var FLOAT16_FOURTH_ROOT_EPS = require( './../lib' );
27+
28+
29+
// TESTS //
30+
31+
tape( 'main export is a number', function test( t ) {
32+
t.ok( true, __filename );
33+
t.strictEqual( typeof FLOAT16_FOURTH_ROOT_EPS, 'number', 'main export is a number' );
34+
t.end();
35+
});
36+
37+
tape( 'the exported value equals the fourth root of the difference between one and the smallest value greater than one which is representable as a double (2**-10)', function test( t ) {
38+
var expected = sqrt( sqrt( pow( 2, -10 ) ) );
39+
t.equal( FLOAT16_FOURTH_ROOT_EPS, expected, 'equals sqrt( sqrt(2**-10) )' );
40+
t.end();
41+
});

0 commit comments

Comments
 (0)