Skip to content

Commit e00e57c

Browse files
committed
[fix]: resolved C linting error
1 parent 1394028 commit e00e57c

File tree

1 file changed

+19
-0
lines changed
  • lib/node_modules/@stdlib/math/base/special/roundn/src

1 file changed

+19
-0
lines changed

lib/node_modules/@stdlib/math/base/special/roundn/src/addon.c

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,26 @@
1616
* limitations under the License.
1717
*/
1818

19+
#include <node_api.h>
20+
#include <math.h>
1921
#include "stdlib/math/base/special/roundn.h"
2022
#include "stdlib/math/base/napi/binary.h"
2123

24+
double stdlib_base_roundn(double x, int n) {
25+
double factor = pow(10, n);
26+
return round(x / factor) * factor;
27+
}
28+
29+
NAPI_MODULE_INIT() {
30+
napi_value fn;
31+
napi_status status = napi_create_function(env, NULL, 0, stdlib_base_roundn, NULL, &fn);
32+
if (status != napi_ok) {
33+
napi_throw_error(env, NULL, "Unable to create function");
34+
return NULL;
35+
}
36+
37+
return fn;
38+
}
39+
40+
2241
STDLIB_MATH_BASE_NAPI_MODULE_DI_D(stdlib_base_roundn)

0 commit comments

Comments
 (0)