Skip to content

Commit 02a6661

Browse files
committed
Auto-generated commit
1 parent 9360f09 commit 02a6661

File tree

25 files changed

+2430
-1
lines changed

25 files changed

+2430
-1
lines changed

CHANGELOG.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,13 @@
44

55
<section class="release" id="unreleased">
66

7-
## Unreleased (2026-01-03)
7+
## Unreleased (2026-01-06)
88

99
<section class="features">
1010

1111
### Features
1212

13+
- [`542d57c`](https://github.com/stdlib-js/stdlib/commit/542d57c97e7b8e8d9b41221d86c5378fa02d0d87) - add `math/base/special/floornf` [(#4881)](https://github.com/stdlib-js/stdlib/pull/4881)
1314
- [`ea8228b`](https://github.com/stdlib-js/stdlib/commit/ea8228b082c03c6c8c8182d237c709ae279c05d2) - add `math/base/special/acoshf` [(#5812)](https://github.com/stdlib-js/stdlib/pull/5812)
1415
- [`e4442f2`](https://github.com/stdlib-js/stdlib/commit/e4442f21bca0114e934d71da6b3d61e54d3a711b) - update math scaffold databases [(#9453)](https://github.com/stdlib-js/stdlib/pull/9453)
1516
- [`15e0b09`](https://github.com/stdlib-js/stdlib/commit/15e0b09a9bda620a7a80e265049d8ffdc2e632b1) - update math scaffold databases [(#9451)](https://github.com/stdlib-js/stdlib/pull/9451)
@@ -712,6 +713,7 @@ A total of 80 issues were closed in this release:
712713

713714
<details>
714715

716+
- [`542d57c`](https://github.com/stdlib-js/stdlib/commit/542d57c97e7b8e8d9b41221d86c5378fa02d0d87) - **feat:** add `math/base/special/floornf` [(#4881)](https://github.com/stdlib-js/stdlib/pull/4881) _(by Gururaj Gurram, Athan Reines, stdlib-bot, Karan Anand)_
715717
- [`27d5d30`](https://github.com/stdlib-js/stdlib/commit/27d5d30af2380909aa925ce955fb7a4b79d5df43) - **style:** fix EditorConfig lint errors [(#9510)](https://github.com/stdlib-js/stdlib/pull/9510) _(by kaushal-kumar-it)_
716718
- [`8289a03`](https://github.com/stdlib-js/stdlib/commit/8289a036ebd5f568c35541a480ccdc341ba706af) - **bench:** refactor to use dynamic memory allocation in `math/strided/special/strunc` [(#9481)](https://github.com/stdlib-js/stdlib/pull/9481) _(by kshitijgarg2811-oss, Athan Reines)_
717719
- [`3ae6e96`](https://github.com/stdlib-js/stdlib/commit/3ae6e9691bbab7f2162ef8bb5e3279aefd517e47) - **chore:** add structured meta data _(by Athan Reines)_

base/special/floornf/README.md

Lines changed: 209 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,209 @@
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+
# floornf
22+
23+
> Round a single-precision floating-point number to the nearest multiple of 10^n toward negative infinity.
24+
25+
<section class="usage">
26+
27+
## Usage
28+
29+
```javascript
30+
var floornf = require( '@stdlib/math/base/special/floornf' );
31+
```
32+
33+
#### floornf( x, n )
34+
35+
Rounds a single-precision floating-point number to the nearest multiple of `10^n` toward negative infinity.
36+
37+
```javascript
38+
// Round a value to 3 decimal places:
39+
var v = floornf( 3.14159, -3 );
40+
// returns ~3.141
41+
42+
// Round a value to the nearest thousand:
43+
v = floornf( 12368.0, 3 );
44+
// returns ~12000.0
45+
46+
// If n = 0, `floornf` behaves like `floorf`:
47+
v = floornf( 3.14159, 0 );
48+
// returns 3.0
49+
```
50+
51+
</section>
52+
53+
<!-- /.usage -->
54+
55+
<section class="notes">
56+
57+
## Notes
58+
59+
- When operating on [floating-point numbers][ieee754] in bases other than `2`, rounding to specified digits can be **inexact**. For example,
60+
61+
```javascript
62+
var f32 = require( '@stdlib/number/float64/base/to-float32' );
63+
64+
var x = f32( f32( -0.2 ) - f32( 0.1 ) );
65+
// returns -0.30000001192092896
66+
67+
// Should round to -0.3:
68+
var v = floornf( x, -8 );
69+
// returns -0.30000001192092896
70+
```
71+
72+
</section>
73+
74+
<!-- /.notes -->
75+
76+
<section class="examples">
77+
78+
## Examples
79+
80+
<!-- eslint no-undef: "error" -->
81+
82+
```javascript
83+
var discreteUniform = require( '@stdlib/random/array/discrete-uniform' );
84+
var uniform = require( '@stdlib/random/array/uniform' );
85+
var logEachMap = require( '@stdlib/console/log-each-map' );
86+
var floornf = require( '@stdlib/math/base/special/floornf' );
87+
88+
var x = uniform( 100, -50.0, 50.0, {
89+
'dtype': 'float32'
90+
});
91+
var n = discreteUniform( 100, -4, 0, {
92+
'dtype': 'int32'
93+
});
94+
95+
logEachMap( 'x: %0.8f. Number of decimals: %d. Rounded: %0.8f', x, n, floornf );
96+
```
97+
98+
</section>
99+
100+
<!-- /.examples -->
101+
102+
<!-- C interface documentation. -->
103+
104+
* * *
105+
106+
<section class="c">
107+
108+
## C APIs
109+
110+
<!-- Section to include introductory text. Make sure to keep an empty line after the intro `section` element and another before the `/section` close. -->
111+
112+
<section class="intro">
113+
114+
</section>
115+
116+
<!-- /.intro -->
117+
118+
<!-- C usage documentation. -->
119+
120+
<section class="usage">
121+
122+
### Usage
123+
124+
```c
125+
#include "stdlib/math/base/special/floornf.h"
126+
```
127+
128+
#### stdlib_base_floornf( x, n )
129+
130+
Rounds a single-precision floating-point number to the nearest multiple of `10^n` toward negative infinity.
131+
132+
```c
133+
// Round a value to 3 decimal places:
134+
float y = stdlib_base_floornf( 3.14159f, -3 );
135+
// returns ~3.141f
136+
137+
// If n = 0, `floornf` behaves like `floorf`:
138+
y = stdlib_base_floornf( 3.14159f, 0 );
139+
// returns 3.0f
140+
```
141+
142+
The function accepts the following arguments:
143+
144+
- **x**: `[in] float` input value.
145+
- **n**: `[in] int32_t` integer power of 10.
146+
147+
```c
148+
float stdlib_base_floornf( const float x, const int32_t n );
149+
```
150+
151+
</section>
152+
153+
<!-- /.usage -->
154+
155+
<!-- C API usage notes. Make sure to keep an empty line after the `section` element and another before the `/section` close. -->
156+
157+
<section class="notes">
158+
159+
</section>
160+
161+
<!-- /.notes -->
162+
163+
<!-- C API usage examples. -->
164+
165+
<section class="examples">
166+
167+
### Examples
168+
169+
```c
170+
#include "stdlib/math/base/special/floornf.h"
171+
#include <stdio.h>
172+
173+
int main( void ) {
174+
const float x[] = { 3.14f, -3.14f, 0.0f, 0.0f/0.0f };
175+
176+
float y;
177+
int i;
178+
for ( i = 0; i < 4; i++ ) {
179+
y = stdlib_base_floornf( x[ i ], -2 );
180+
printf( "floornf(%f, -2) = %f\n", x[ i ], y );
181+
}
182+
}
183+
```
184+
185+
</section>
186+
187+
<!-- /.examples -->
188+
189+
</section>
190+
191+
<!-- /.c -->
192+
193+
<!-- Section for related `stdlib` packages. Do not manually edit this section, as it is automatically populated. -->
194+
195+
<section class="related">
196+
197+
</section>
198+
199+
<!-- /.related -->
200+
201+
<!-- Section for all links. Make sure to keep an empty line after the `section` element and another before the `/section` close. -->
202+
203+
<section class="links">
204+
205+
[ieee754]: https://en.wikipedia.org/wiki/IEEE_754-1985
206+
207+
</section>
208+
209+
<!-- /.links -->
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
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 bench = require( '@stdlib/bench' );
24+
var uniform = require( '@stdlib/random/array/uniform' );
25+
var isnanf = require( './../../../../base/assert/is-nanf' );
26+
var pkg = require( './../package.json' ).name;
27+
var floornf = require( './../lib' );
28+
29+
30+
// MAIN //
31+
32+
bench( pkg, function benchmark( b ) {
33+
var x;
34+
var y;
35+
var i;
36+
37+
x = uniform( 100, -500.0, 500.0, {
38+
'dtype': 'float32'
39+
});
40+
41+
b.tic();
42+
for ( i = 0; i < b.iterations; i++ ) {
43+
y = floornf( x[ i%x.length ], -2 );
44+
if ( isnanf( y ) ) {
45+
b.fail( 'should not return NaN' );
46+
}
47+
}
48+
b.toc();
49+
if ( isnanf( y ) ) {
50+
b.fail( 'should not return NaN' );
51+
}
52+
b.pass( 'benchmark finished' );
53+
b.end();
54+
});
Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
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 resolve = require( 'path' ).resolve;
24+
var bench = require( '@stdlib/bench' );
25+
var uniform = require( '@stdlib/random/array/uniform' );
26+
var isnanf = require( './../../../../base/assert/is-nanf' );
27+
var tryRequire = require( '@stdlib/utils/try-require' );
28+
var pkg = require( './../package.json' ).name;
29+
30+
31+
// VARIABLES //
32+
33+
var floornf = tryRequire( resolve( __dirname, './../lib/native.js' ) );
34+
var opts = {
35+
'skip': ( floornf instanceof Error )
36+
};
37+
38+
39+
// MAIN //
40+
41+
bench( pkg+'::native', opts, function benchmark( b ) {
42+
var x;
43+
var y;
44+
var i;
45+
46+
x = uniform( 100, -500.0, 500.0, {
47+
'dtype': 'float32'
48+
});
49+
50+
b.tic();
51+
for ( i = 0; i < b.iterations; i++ ) {
52+
y = floornf( x[ i%x.length ], -2 );
53+
if ( isnanf( y ) ) {
54+
b.fail( 'should not return NaN' );
55+
}
56+
}
57+
b.toc();
58+
if ( isnanf( y ) ) {
59+
b.fail( 'should not return NaN' );
60+
}
61+
b.pass( 'benchmark finished' );
62+
b.end();
63+
});

0 commit comments

Comments
 (0)