Skip to content

Commit 3e0a88f

Browse files
committed
feat: add number/float32/base/ulp-difference
--- type: pre_commit_static_analysis_report description: Results of running static analysis checks when committing changes. report: - task: lint_filenames status: passed - task: lint_editorconfig status: passed - task: lint_markdown status: passed - task: lint_package_json status: passed - task: lint_repl_help status: passed - task: lint_javascript_src status: na - task: lint_javascript_cli status: na - task: lint_javascript_examples status: passed - task: lint_javascript_tests status: na - task: lint_javascript_benchmarks status: passed - task: lint_python status: na - task: lint_r status: na - task: lint_c_src status: na - task: lint_c_examples status: na - task: lint_c_benchmarks status: na - task: lint_c_tests_fixtures status: na - task: lint_shell status: na - task: lint_typescript_declarations status: passed - task: lint_typescript_tests status: na - task: lint_license_headers status: passed ---
1 parent 1796f6e commit 3e0a88f

File tree

6 files changed

+39
-25
lines changed

6 files changed

+39
-25
lines changed

lib/node_modules/@stdlib/number/float32/base/ulp-difference/README.md

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ limitations under the License.
2020

2121
# ulpdiff
2222

23-
> Compute the number of representable [double-precision][double-precision] floating-point values that separate two [double-precision][double-precision] floating-point numbers along the real number line.
23+
> Compute the number of representable [single-precision][single-precision] floating-point values that separate two [single-precision][single-precision] floating-point numbers along the real number line.
2424
2525
<!-- Section to include introductory text. Make sure to keep an empty line after the intro `section` element and another before the `/section` close. -->
2626

@@ -37,15 +37,15 @@ limitations under the License.
3737
## Usage
3838

3939
```javascript
40-
var ulpdiff = require( '@stdlib/number/float64/base/ulp-difference' );
40+
var ulpdiff = require( '@stdlib/number/float32/base/ulp-difference' );
4141
```
4242

4343
#### ulpdiff( x, y )
4444

45-
Computes the number of representable [double-precision][double-precision] floating-point values that separate two [double-precision][double-precision] floating-point numbers along the real number line.
45+
Computes the number of representable [single-precision][single-precision] floating-point values that separate two [single-precision][single-precision] floating-point numbers along the real number line.
4646

4747
```javascript
48-
var EPS = require( '@stdlib/constants/float64/eps' );
48+
var EPS = require( '@stdlib/constants/float32/eps' );
4949

5050
var d = ulpdiff( 1.0, 1.0+EPS );
5151
// returns 1.0
@@ -76,7 +76,7 @@ d = ulpdiff( NaN, NaN );
7676

7777
## Notes
7878

79-
- Adjacent [double-precision][double-precision] floating-point numbers differ by `1` [ulp][ulp] (unit in the last place).
79+
- Adjacent [single-precision][single-precision] floating-point numbers differ by `1` [ulp][ulp] (unit in the last place).
8080
- Signed zeros differ only in the sign bit but are considered numerically equal, and thus their ULP difference is `0`.
8181

8282
</section>
@@ -92,24 +92,29 @@ d = ulpdiff( NaN, NaN );
9292
<!-- eslint no-undef: "error" -->
9393

9494
```javascript
95-
var EPS = require( '@stdlib/constants/float64/eps' );
96-
var SMALLEST_SUBNORMAL = require( '@stdlib/constants/float64/smallest-subnormal' );
97-
var ulpdiff = require( '@stdlib/number/float64/base/ulp-difference' );
95+
var EPS = require( '@stdlib/constants/float32/eps' );
96+
var SMALLEST_SUBNORMAL = require( '@stdlib/constants/float32/smallest-subnormal' );
97+
var ulpdiff = require( '@stdlib/number/float32/base/ulp-difference' );
9898

9999
var d = ulpdiff( 1.0, 1.0+EPS );
100100
console.log( d );
101+
// => 1.0
101102

102-
d = ulpdiff( 5.8364e-319, 5.8367e-319 );
103+
d = ulpdiff( 5.8364e-31, 5.8367e-31 );
103104
console.log( d );
105+
// => 638.0
104106

105107
d = ulpdiff( 0.0, SMALLEST_SUBNORMAL );
106108
console.log( d );
109+
// => 1.0
107110

108111
d = ulpdiff( 0.0, -0.0 );
109112
console.log( d );
113+
// => 0.0
110114

111115
d = ulpdiff( SMALLEST_SUBNORMAL, -SMALLEST_SUBNORMAL );
112116
console.log( d );
117+
// => 2.0
113118
```
114119

115120
</section>
@@ -128,7 +133,7 @@ console.log( d );
128133

129134
<section class="links">
130135

131-
[double-precision]: https://en.wikipedia.org/wiki/Double-precision_floating-point_format
136+
[single-precision]: https://en.wikipedia.org/wiki/Single-precision_floating-point_format
132137

133138
[ulp]: https://en.wikipedia.org/wiki/Unit_in_the_last_place
134139

lib/node_modules/@stdlib/number/float32/base/ulp-difference/benchmark/benchmark.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,12 +30,16 @@ var ulpdiff = require( './../lib' );
3030
// MAIN //
3131

3232
bench( pkg, function benchmark( b ) {
33+
var opts;
3334
var x;
3435
var y;
3536
var i;
3637

37-
x = uniform( 100, -500.0, 500.0 );
38-
y = uniform( 100, -500.0, 500.0 );
38+
opts = {
39+
'dtype': 'float32'
40+
};
41+
x = uniform( 100, -500.0, 500.0, opts );
42+
y = uniform( 100, -500.0, 500.0, opts );
3943

4044
b.tic();
4145
for ( i = 0; i < b.iterations; i++ ) {

lib/node_modules/@stdlib/number/float32/base/ulp-difference/docs/repl.txt

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11

22
{{alias}}( x, y )
3-
Computes the number of representable double-precision floating-point values
4-
that separate two double-precision floating-point numbers along the real
3+
Computes the number of representable single-precision floating-point values
4+
that separate two single-precision floating-point numbers along the real
55
number line.
66

7-
Adjacent double-precision floating-point numbers differ by 1 ulp (unit in
7+
Adjacent single-precision floating-point numbers differ by 1 ulp (unit in
88
the last place).
99

1010
Signed zeros differ only in the sign bit but are considered numerically
@@ -27,11 +27,11 @@
2727

2828
Examples
2929
--------
30-
> var v = {{alias}}( 1.0, 1.0+{{alias:@stdlib/constants/float64/eps}} )
30+
> var v = {{alias}}( 1.0, 1.0+{{alias:@stdlib/constants/float32/eps}} )
3131
1.0
32-
> v = {{alias}}( 1.0+{{alias:@stdlib/constants/float64/eps}}, 1.0 )
32+
> v = {{alias}}( 1.0+{{alias:@stdlib/constants/float32/eps}}, 1.0 )
3333
1.0
34-
> v = {{alias}}( 1.0, 1.0+{{alias:@stdlib/constants/float64/eps}}*2.0 )
34+
> v = {{alias}}( 1.0, 1.0+{{alias:@stdlib/constants/float32/eps}}*2.0 )
3535
2.0
3636
> v = {{alias}}( 1.0, NaN )
3737
NaN

lib/node_modules/@stdlib/number/float32/base/ulp-difference/docs/types/index.d.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,19 +19,19 @@
1919
// TypeScript Version: 4.1
2020

2121
/**
22-
* Computes the number of representable double-precision floating-point values that separate two double-precision floating-point numbers along the real number line.
22+
* Computes the number of representable single-precision floating-point values that separate two single-precision floating-point numbers along the real number line.
2323
*
2424
* ## Notes
2525
*
26-
* - Adjacent double-precision floating-point numbers differ by 1 ulp (unit in the last place).
26+
* - Adjacent single-precision floating-point numbers differ by 1 ulp (unit in the last place).
2727
* - Signed zeros differ only in the sign bit but are considered numerically equal, and thus their ULP difference is 0.
2828
*
2929
* @param x - first input value
3030
* @param y - second input value
3131
* @returns result
3232
*
3333
* @example
34-
* var EPS = require( '@stdlib/constants/float64/eps' );
34+
* var EPS = require( '@stdlib/constants/float32/eps' );
3535
*
3636
* var d = ulpdiff( 1.0, 1.0+EPS );
3737
* // returns 1.0

lib/node_modules/@stdlib/number/float32/base/ulp-difference/examples/index.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,15 +24,20 @@ var ulpdiff = require( './../lib' );
2424

2525
var d = ulpdiff( 1.0, 1.0+EPS );
2626
console.log( d );
27+
// => 1.0
2728

28-
d = ulpdiff( 5.8364e-319, 5.8367e-319 );
29+
d = ulpdiff( 5.8364e-31, 5.8367e-31 );
2930
console.log( d );
31+
// => 638.0
3032

3133
d = ulpdiff( 0.0, SMALLEST_SUBNORMAL );
3234
console.log( d );
35+
// => 1.0
3336

3437
d = ulpdiff( 0.0, -0.0 );
3538
console.log( d );
39+
// => 0.0
3640

3741
d = ulpdiff( SMALLEST_SUBNORMAL, -SMALLEST_SUBNORMAL );
3842
console.log( d );
43+
// => 2.0

lib/node_modules/@stdlib/number/float32/base/ulp-difference/package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
2-
"name": "@stdlib/number/float64/base/ulp-difference",
2+
"name": "@stdlib/number/float32/base/ulp-difference",
33
"version": "0.0.0",
4-
"description": "Compute the number of representable double-precision floating-point values that separate two double-precision floating-point numbers along the real number line.",
4+
"description": "Compute the number of representable single-precision floating-point values that separate two single-precision floating-point numbers along the real number line.",
55
"license": "Apache-2.0",
66
"author": {
77
"name": "The Stdlib Authors",
@@ -62,7 +62,7 @@
6262
"dist",
6363
"numbers",
6464
"ulp",
65-
"float64",
65+
"float32",
6666
"double"
6767
]
6868
}

0 commit comments

Comments
 (0)