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 23, 2024
1 parent 1c4e07c commit 9550c8f
Show file tree
Hide file tree
Showing 12 changed files with 573 additions and 2 deletions.
65 changes: 65 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,71 @@

> Package changelog.
<section class="release" id="unreleased">

## Unreleased (2024-08-23)

<section class="packages">

### Packages

<section class="package" id="constants-float32-max-safe-nth-factorial-unreleased">

#### [@stdlib/constants/float32/max-safe-nth-factorial](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/constants/float32/max-safe-nth-factorial)

<details>

<section class="features">

##### Features

- [`8552f2c`](https://github.com/stdlib-js/stdlib/commit/8552f2c71db0996da51c6170dd9dc834ac74a43c) - add `constants/float32/max-safe-nth-factorial` [(#2821)](https://github.com/stdlib-js/stdlib/pull/2821)

</section>

<!-- /.features -->

</details>

</section>

<!-- /.package -->

</section>

<!-- /.packages -->

<section class="contributors">

### Contributors

A total of 2 people contributed to this release. Thank you to the following contributors:

- Athan Reines
- Gunj Joshi

</section>

<!-- /.contributors -->

<section class="commits">

### Commits

<details>

- [`8552f2c`](https://github.com/stdlib-js/stdlib/commit/8552f2c71db0996da51c6170dd9dc834ac74a43c) - **feat:** add `constants/float32/max-safe-nth-factorial` [(#2821)](https://github.com/stdlib-js/stdlib/pull/2821) _(by Gunj Joshi, Athan Reines)_

</details>

</section>

<!-- /.commits -->

</section>

<!-- /.release -->

<section class="release" id="v0.3.1">

## 0.3.1 (2024-08-18)
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -173,8 +173,8 @@ Copyright &copy; 2016-2024. The Stdlib [Authors][stdlib-authors].
[npm-image]: http://img.shields.io/npm/v/@stdlib/constants.svg
[npm-url]: https://npmjs.org/package/@stdlib/constants

[test-image]: https://github.com/stdlib-js/constants/actions/workflows/test.yml/badge.svg?branch=v0.3.1
[test-url]: https://github.com/stdlib-js/constants/actions/workflows/test.yml?query=branch:v0.3.1
[test-image]: https://github.com/stdlib-js/constants/actions/workflows/test.yml/badge.svg?branch=main
[test-url]: https://github.com/stdlib-js/constants/actions/workflows/test.yml?query=branch:main

[coverage-image]: https://img.shields.io/codecov/c/github/stdlib-js/constants/main.svg
[coverage-url]: https://codecov.io/github/stdlib-js/constants?branch=main
Expand Down
166 changes: 166 additions & 0 deletions float32/max-safe-nth-factorial/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,166 @@
<!--
@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.
-->

# FLOAT32_MAX_SAFE_NTH_FACTORIAL

> Maximum safe nth [factorial][factorial] when stored in [single-precision floating-point][ieee754] format.
<section class="usage">

## Usage

<!-- eslint-disable id-length -->

```javascript
var FLOAT32_MAX_SAFE_NTH_FACTORIAL = require( '@stdlib/constants/float32/max-safe-nth-factorial' );
```

#### FLOAT32_MAX_SAFE_NTH_FACTORIAL

The maximum [safe][safe-integers] nth [factorial][factorial] when stored in [single-precision floating-point][ieee754] format.

<!-- eslint-disable id-length -->

```javascript
var bool = ( FLOAT32_MAX_SAFE_NTH_FACTORIAL === 34 );
// returns true
```

</section>

<!-- /.usage -->

<section class="examples">

## Examples

<!-- eslint-disable id-length -->

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

```javascript
var FLOAT32_MAX_SAFE_NTH_FACTORIAL = require( '@stdlib/constants/float32/max-safe-nth-factorial' );

function factorial( n ) {
var a;
var i;

a = 1;
for ( i = 2; i <= n; i++ ) {
a *= i;
}
return a;
}

var v;
var i;
for ( i = 0; i < 100; i++ ) {
v = factorial( i );
if ( i > FLOAT32_MAX_SAFE_NTH_FACTORIAL ) {
console.log( 'Unsafe: %d', v );
} else {
console.log( 'Safe: %d', v );
}
}
```

</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/constants/float32/max_safe_nth_factorial.h"
```

#### STDLIB_CONSTANT_FLOAT32_MAX_SAFE_NTH_FACTORIAL

Macro for the maximum [safe][safe-integers] nth [factorial][factorial] when stored in [single-precision floating-point][ieee754] format.

</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">

</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">

[safe-integers]: http://www.2ality.com/2013/10/safe-integers.html

[factorial]: https://en.wikipedia.org/wiki/Factorial

[ieee754]: https://en.wikipedia.org/wiki/IEEE_754-1985

<!-- <related-links> -->

<!-- </related-links> -->

</section>

<!-- /.links -->
13 changes: 13 additions & 0 deletions float32/max-safe-nth-factorial/docs/repl.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@

{{alias}}
Maximum safe nth factorial when stored in single-precision floating-
point format.

Examples
--------
> {{alias}}
34

See Also
--------

33 changes: 33 additions & 0 deletions float32/max-safe-nth-factorial/docs/types/index.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
/*
* @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.
*/

// TypeScript Version: 4.1

/**
* Maximum safe nth factorial when stored in single-precision floating-point format.
*
* @example
* var max = FLOAT32_MAX_SAFE_NTH_FACTORIAL;
* // returns 34
*/
declare const FLOAT32_MAX_SAFE_NTH_FACTORIAL: number;


// EXPORTS //

export = FLOAT32_MAX_SAFE_NTH_FACTORIAL;
28 changes: 28 additions & 0 deletions float32/max-safe-nth-factorial/docs/types/test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
/*
* @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.
*/

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


// TESTS //

// The export is a number...
{
// eslint-disable-next-line @typescript-eslint/no-unused-expressions
FLOAT32_MAX_SAFE_NTH_FACTORIAL; // $ExpectType number
}
43 changes: 43 additions & 0 deletions float32/max-safe-nth-factorial/examples/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
/**
* @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';

var FLOAT32_MAX_SAFE_NTH_FACTORIAL = require( './../lib' ); // eslint-disable-line id-length

function factorial( n ) {
var a;
var i;

a = 1;
for ( i = 2; i <= n; i++ ) {
a *= i;
}
return a;
}

var v;
var i;
for ( i = 0; i < 100; i++ ) {
v = factorial( i );
if ( i > FLOAT32_MAX_SAFE_NTH_FACTORIAL ) {
console.log( 'Unsafe: %d', v );
} else {
console.log( 'Safe: %d', v );
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
/**
* @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.
*/

#ifndef STDLIB_CONSTANTS_FLOAT32_MAX_SAFE_NTH_FACTORIAL_H
#define STDLIB_CONSTANTS_FLOAT32_MAX_SAFE_NTH_FACTORIAL_H

/**
* Macro for the maximum safe nth factorial when stored in single-precision floating-point format.
*/
#define STDLIB_CONSTANT_FLOAT32_MAX_SAFE_NTH_FACTORIAL 34

#endif // !STDLIB_CONSTANTS_FLOAT32_MAX_SAFE_NTH_FACTORIAL_H
Loading

0 comments on commit 9550c8f

Please sign in to comment.