Skip to content

Commit

Permalink
Auto-generated commit
Browse files Browse the repository at this point in the history
  • Loading branch information
stdlib-bot committed Aug 8, 2024
1 parent 1b19074 commit c0cbb69
Show file tree
Hide file tree
Showing 25 changed files with 1,954 additions and 0 deletions.
23 changes: 23 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,28 @@

<!-- /.package -->

<section class="package" id="math-base-assert-is-integerf-unreleased">

#### [@stdlib/math/base/assert/is-integerf](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/math/base/assert/is-integerf)

<details>

<section class="features">

##### Features

- [`140b517`](https://github.com/stdlib-js/stdlib/commit/140b5172075f08678b84b5f92b7feeacfc777119) - add `math/base/assert/is-integerf`

</section>

<!-- /.features -->

</details>

</section>

<!-- /.package -->

<section class="package" id="math-base-assert-is-negative-finite-unreleased">

#### [@stdlib/math/base/assert/is-negative-finite](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/math/base/assert/is-negative-finite)
Expand Down Expand Up @@ -5885,6 +5907,7 @@ A total of 30 people contributed to this release. Thank you to the following con

<details>

- [`140b517`](https://github.com/stdlib-js/stdlib/commit/140b5172075f08678b84b5f92b7feeacfc777119) - **feat:** add `math/base/assert/is-integerf` _(by Gunj Joshi, Philipp Burckhardt)_
- [`2837436`](https://github.com/stdlib-js/stdlib/commit/283743652091fff85f01746b9edf8da3d5286cf5) - **docs:** update license header in `math/base/special/gamma1pm1` [(#2764)](https://github.com/stdlib-js/stdlib/pull/2764) _(by Gunj Joshi)_
- [`c14e9c3`](https://github.com/stdlib-js/stdlib/commit/c14e9c3c5b43e13f53e20f87b51868e49b8b7882) - **docs:** update license header and remove `stdlib` include in `math/base/special/trigamma` _(by Gunj Joshi)_
- [`82f78f2`](https://github.com/stdlib-js/stdlib/commit/82f78f2a48a3dd406afbed1a3aa2891ecbc94ab6) - **docs:** update function description comments in `math/base/special/betaln` _(by Gunj Joshi)_
Expand Down
202 changes: 202 additions & 0 deletions base/assert/is-integerf/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,202 @@
<!--
@license Apache-2.0
Copyright (c) 2024 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.
-->

# isIntegerf

> Test if a finite [single-precision floating-point number][ieee754] is an integer.
<section class="usage">

## Usage

```javascript
var isIntegerf = require( '@stdlib/math/base/assert/is-integerf' );
```

#### isIntegerf( x )

Tests if a finite [single-precision floating-point number][ieee754] is an integer.

```javascript
var bool = isIntegerf( 1.0 );
// returns true
```

</section>

<!-- /.usage -->

<section class="notes">

## Notes

- The function assumes a **finite** number. If provided positive or negative `infinity`, the function will return `true`, when, in fact, the result is undefined. If `x` can be `infinite`, wrap the implementation as follows:

```javascript
function check( x ) {
return (
x < Infinity &&
x > -Infinity &&
isIntegerf( x )
);
}

var bool = check( Infinity );
// returns false

bool = check( -Infinity );
// returns false
```

</section>

<!-- /.notes -->

<section class="examples">

## Examples

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

```javascript
var isIntegerf = require( '@stdlib/math/base/assert/is-integerf' );
var bool = isIntegerf( -5.0 );
// returns true
bool = isIntegerf( 3.14 );
// returns false
bool = isIntegerf( NaN );
// returns false
```

</section>

<!-- /.examples -->

<!-- C interface documentation. -->

* * *

<section class="c">

## C APIs

<!-- Section to include introductory text. Make sure to keep an empty line after the intro `section` element and another before the `/section` close. -->

<section class="intro">

</section>

<!-- /.intro -->

<!-- C usage documentation. -->

<section class="usage">

### Usage

```c
#include "stdlib/math/base/assert/is_integerf.h"
```

#### stdlib_base_is_integerf( x )

Tests if a finite [single-precision floating-point number][ieee754] is an integer.

```c
bool out = stdlib_base_is_integerf( 1.0 );
// returns true
out = stdlib_base_is_integerf( 3.14 );
// returns false
```

The function accepts the following arguments:

- **x**: `[in] float` input value.

```c
bool stdlib_base_is_integerf( const float x );
```
</section>
<!-- /.usage -->
<!-- C API usage notes. Make sure to keep an empty line after the `section` element and another before the `/section` close. -->
<section class="notes">
</section>
<!-- /.notes -->
<!-- C API usage examples. -->
<section class="examples">
### Examples
```c
#include "stdlib/math/base/assert/is_integerf.h"
#include <stdio.h>
#include <stdlib.h>
#include <stdbool.h>

int main( void ) {
float x;
bool v;
int i;

for ( i = 0; i < 100; i++ ) {
x = ( ( (float)rand() / (float)RAND_MAX ) * 100.0f ) - 50.0f;
v = stdlib_base_is_integerf( x );
printf( "x = %f, is_integerf(x) = %s\n", x, ( v ) ? "true" : "false" );
}
}
```
</section>
<!-- /.examples -->
</section>
<!-- /.c -->
<!-- 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">
[ieee754]: https://en.wikipedia.org/wiki/IEEE_754-1985
</section>
<!-- /.links -->
121 changes: 121 additions & 0 deletions base/assert/is-integerf/benchmark/benchmark.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,121 @@
/**
* @license Apache-2.0
*
* Copyright (c) 2024 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 bench = require( '@stdlib/bench' );
var isBoolean = require( '@stdlib/assert/is-boolean' ).isPrimitive;
var pkg = require( './../package.json' ).name;
var isIntegerf = require( './../lib' );


// MAIN //

bench( pkg+'::true', function benchmark( b ) {
var values;
var bool;
var i;

values = [
0,
1,
2,
3,
4,
5,
6,
7,
8,
9,
1.0e38,
10,
-0,
-1,
-2,
-3,
-4,
-5,
-6,
-7,
-8,
-9,
-10,
-1.0e38
];

b.tic();
for ( i = 0; i < b.iterations; i++ ) {
bool = isIntegerf( values[ i % values.length ] );
if ( typeof bool !== 'boolean' ) {
b.fail( 'should return a boolean' );
}
}
b.toc();
if ( !isBoolean( bool ) && bool !== true ) {
b.fail( 'should return true' );
}
b.pass( 'benchmark finished' );
b.end();
});

bench( pkg+'::false', function benchmark( b ) {
var values;
var bool;
var i;

values = [
0.1,
1.1,
2.1,
3.1,
4.1,
5.1,
6.1,
7.1,
8.1,
9.1,
10.1,
-0.1,
-1.1,
-2.1,
-3.1,
-4.1,
-5.1,
-6.1,
-7.1,
-8.1,
-9.1,
-10.1
];

b.tic();
for ( i = 0; i < b.iterations; i++ ) {
bool = isIntegerf( values[ i % values.length ] );
if ( typeof bool !== 'boolean' ) {
b.fail( 'should return a boolean' );
}
}
b.toc();
if ( !isBoolean( bool ) && bool !== false ) {
b.fail( 'should return false' );
}
b.pass( 'benchmark finished' );
b.end();
});
Loading

0 comments on commit c0cbb69

Please sign in to comment.