Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add constants/float16/fourth-root-eps #6497

Open
wants to merge 3 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
<!--

@license Apache-2.0

Copyright (c) 2025 The Stdlib Authors.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

-->

# FLOAT16_FOURTH_ROOT_EPS

> [Fourth root][nth-root] of [half-precision floating-point epsilon][@stdlib/constants/float16/eps].

<section class="usage">

## Usage

```javascript
var FLOAT16_FOURTH_ROOT_EPS = require( '@stdlib/constants/float16/fourth-root-eps' );
```

#### FLOAT16_FOURTH_ROOT_EPS

[Fourth root][nth-root] of [half-precision floating-point epsilon][@stdlib/constants/float16/eps].

```javascript
var bool = ( FLOAT16_FOURTH_ROOT_EPS === 0.1767766952966369 );
// returns true
```

</section>

<!-- /.usage -->

<section class="examples">

## Examples

<!-- eslint no-undef: "error" -->

```javascript
var FLOAT16_FOURTH_ROOT_EPS = require( '@stdlib/constants/float16/fourth-root-eps' );

var out = FLOAT16_FOURTH_ROOT_EPS;
// returns 0.1767766952966369
```

</section>

<!-- Section for related `stdlib` packages. Do not manually edit this section, as it is automatically populated. -->

<section class="related">

</section>

<!-- /.related -->

<!-- Section for all links. Make sure to keep an empty line after the `section` element and another before the `/section` close. -->

<section class="links">

[nth-root]: https://en.wikipedia.org/wiki/Nth_root
[@stdlib/constants/float16/eps]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/constants/float16/eps

</section>

<!-- /.links -->
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@

{{alias}}
Fourth root of half-precision floating-point epsilon.

Examples
--------
> {{alias}}
0.1767766952966369

See Also
--------
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
/*
* @license Apache-2.0
*
* Copyright (c) 2025 The Stdlib Authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

// TypeScript Version: 4.1

/**
* Fourth root of half-precision floating-point epsilon.
*
* @example
* var eps = FLOAT16_FOURTH_ROOT_EPS;
* // returns 0.1767766952966369
*/
declare const FLOAT16_FOURTH_ROOT_EPS: number;


// EXPORTS //

export = FLOAT16_FOURTH_ROOT_EPS;
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
/*
* @license Apache-2.0
*
* Copyright (c) 2025 The Stdlib Authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

import FLOAT16_FOURTH_ROOT_EPS = require( './index' );


// TESTS //

// The export is a number...
{
// eslint-disable-next-line @typescript-eslint/no-unused-expressions
FLOAT16_FOURTH_ROOT_EPS; // $ExpectType number
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
/**
* @license Apache-2.0
*
* Copyright (c) 2025 The Stdlib Authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

'use strict';

var FLOAT16_FOURTH_ROOT_EPS = require( './../lib' );

console.log( FLOAT16_FOURTH_ROOT_EPS );
// => 0.1767766952966369
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
/**
* @license Apache-2.0
*
* Copyright (c) 2025 The Stdlib Authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

'use strict';

/**
* Fourth root of half-precision floating-point epsilon.
*
* @module @stdlib/constants/float16/fourth-root-eps
* @type {number}
*
* @example
* var FLOAT16_FOURTH_ROOT_EPS = require( '@stdlib/constants/float16/fourth-root-eps' );
* // returns 0.1767766952966369
*/


// MAIN //

/**
* Fourth root of half-precision floating-point epsilon.
*
* ```tex
* \sqrt{\sqrt{\frac{1}{2^{10}}}}
* ```
*
* @constant
* @type {number}
* @default 0.1767766952966369
* @see [IEEE 754]{@link https://en.wikipedia.org/wiki/IEEE_754-1985}
* @see [Half-precision floating-point format]{@link https://en.wikipedia.org/wiki/Half-precision_floating-point_format}
*/
var FLOAT16_FOURTH_ROOT_EPS = 0.1767766952966369;


// EXPORTS //

module.exports = FLOAT16_FOURTH_ROOT_EPS;
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
{
"name": "@stdlib/constants/float16/fourth-root-eps",
"version": "0.0.0",
"description": "Fourth root of half-precision floating-point epsilon.",
"license": "Apache-2.0",
"author": {
"name": "The Stdlib Authors",
"url": "https://github.com/stdlib-js/stdlib/graphs/contributors"
},
"contributors": [
{
"name": "The Stdlib Authors",
"url": "https://github.com/stdlib-js/stdlib/graphs/contributors"
}
],
"main": "./lib",
"directories": {
"doc": "./docs",
"example": "./examples",
"lib": "./lib",
"test": "./test"
},
"types": "./docs/types",
"scripts": {},
"homepage": "https://github.com/stdlib-js/stdlib",
"repository": {
"type": "git",
"url": "git://github.com/stdlib-js/stdlib.git"
},
"bugs": {
"url": "https://github.com/stdlib-js/stdlib/issues"
},
"dependencies": {},
"devDependencies": {},
"engines": {
"node": ">=0.10.0",
"npm": ">2.7.0"
},
"os": [
"aix",
"darwin",
"freebsd",
"linux",
"macos",
"openbsd",
"sunos",
"win32",
"windows"
],
"keywords": [
"stdlib",
"stdmath",
"constant",
"const",
"mathematics",
"math",
"double",
"dbl",
"floating-point",
"float",
"float16",
"16bit",
"16-bit",
"ieee754",
"epsilon",
"eps",
"number",
"sqrt",
"fourth",
"root"
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
/**
* @license Apache-2.0
*
* Copyright (c) 2025 The Stdlib Authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

'use strict';

// MODULES //

var tape = require( 'tape' );
var pow = require( '@stdlib/math/base/special/pow' );
var sqrt = require( '@stdlib/math/base/special/sqrt' );
var FLOAT16_FOURTH_ROOT_EPS = require( './../lib' );


// TESTS //

tape( 'main export is a number', function test( t ) {
t.ok( true, __filename );
t.strictEqual( typeof FLOAT16_FOURTH_ROOT_EPS, 'number', 'main export is a number' );
t.end();
});

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 ) {
var expected = sqrt( sqrt( pow( 2, -10 ) ) );
t.equal( FLOAT16_FOURTH_ROOT_EPS, expected, 'equals sqrt( sqrt(2**-10) )' );
t.end();
});