Skip to content

Commit 3667112

Browse files
authored
Apply suggestions from code review
Signed-off-by: Athan <[email protected]>
1 parent 8db1788 commit 3667112

File tree

2 files changed

+9
-9
lines changed
  • lib/node_modules/@stdlib/math/base/napi/unary

2 files changed

+9
-9
lines changed

lib/node_modules/@stdlib/math/base/napi/unary/README.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -306,14 +306,14 @@ void stdlib_math_base_napi_d_d( napi_env env, napi_callback_info info, double (*
306306
Macro for registering a Node-API module exporting an interface for invoking a unary function accepting a double-precision floating-point number and returning a single-precision floating-point number.
307307
308308
```c
309-
static float scale( const double x ) {
310-
return x * 10.0f;
309+
static float fcn( const double x ) {
310+
return (float)x;
311311
}
312312
313313
// ...
314314
315315
// Register a Node-API module:
316-
STDLIB_MATH_BASE_NAPI_MODULE_D_F( scale );
316+
STDLIB_MATH_BASE_NAPI_MODULE_D_F( fcn );
317317
```
318318

319319
The macro expects the following arguments:
@@ -331,8 +331,8 @@ Invokes a unary function accepting a double-precision floating-point number and
331331

332332
// ...
333333

334-
static float identityf( const double x ) {
335-
return x;
334+
static float fcn( const double x ) {
335+
return (float)x;
336336
}
337337

338338
// ...
@@ -345,7 +345,7 @@ static float identityf( const double x ) {
345345
* @return Node-API value
346346
*/
347347
napi_value addon( napi_env env, napi_callback_info info ) {
348-
return stdlib_math_base_napi_d_f( env, info, identityf );
348+
return stdlib_math_base_napi_d_f( env, info, fcn );
349349
}
350350

351351
// ...

lib/node_modules/@stdlib/math/base/napi/unary/include/stdlib/math/base/napi/unary/d_f.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,14 +28,14 @@
2828
* @param fcn unary function
2929
*
3030
* @example
31-
* static float scale( const double x ) {
32-
* return x * 10.0f;
31+
* static float fcn( const double x ) {
32+
* return (float)x;
3333
* }
3434
*
3535
* // ...
3636
*
3737
* // Register a Node-API module:
38-
* STDLIB_MATH_BASE_NAPI_MODULE_D_F( scale );
38+
* STDLIB_MATH_BASE_NAPI_MODULE_D_F( fcn );
3939
*/
4040
#define STDLIB_MATH_BASE_NAPI_MODULE_D_F( fcn ) \
4141
static napi_value stdlib_math_base_napi_d_f_wrapper( \

0 commit comments

Comments
 (0)