feat: add math/base/special/truncbf#8915
feat: add math/base/special/truncbf#8915Amansingh0807 wants to merge 2 commits intostdlib-js:developfrom
math/base/special/truncbf#8915Conversation
| * limitations under the License. | ||
| */ | ||
|
|
||
| #include "stdlib/math/base/special/truncbf.h" |
There was a problem hiding this comment.
You don't need to manually do argument munging. You can use an existing macro. E.g., https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/math/base/napi/ternary#stdlib_math_base_napi_module_dii_d-fcn-
| #include "stdlib/math/base/special/pow.h" | ||
| #include "stdlib/math/base/special/trunc.h" |
There was a problem hiding this comment.
You need to use single-precision packages.
| "task": "build", | ||
| "wasm": false, | ||
| "src": [ | ||
| "./src/main.c", |
There was a problem hiding this comment.
You need to study other packages to see what gets counted as source and what doesn't.
There was a problem hiding this comment.
Yeah Sure, i will do it.
Coverage Report
The above coverage report was generated for the changes in this PR. |
|
@kgryte I have addressed all your feedback:
Additionally, I fixed the benchmarks to use |
4ed17b6 to
ab5e9a8
Compare
|
Hi @kgryte Just a quick update: I have squashed the commit history into a single clean commit to facilitate the review. In addition to the requested fixes (macros, single-precision types), Overflow Protection: Handling cases where the scale factor JS Parity: Enforced strict |
Implement single-precision floating-point truncation function that rounds toward zero to n digits in base b. Features: - C implementation with native addon support - Single-precision operations using powf and truncf - Overflow handling when scale factor becomes infinite - Comprehensive tests (23 test cases) - Benchmarks for C, native, Julia, and JavaScript - TypeScript declarations and documentation - Support for arbitrary base b - Proper handling of edge cases (NaN, ±0, ±Infinity, base=0) Addresses maintainer feedback: - Uses single-precision packages (powf, truncf) - Uses NAPI macro STDLIB_MATH_BASE_NAPI_MODULE_FII_F - Proper manifest.json structure (only main.c in src) Closes stdlib-js#649
ab5e9a8 to
539f58a
Compare
type: pre_commit_static_analysis_report
description: Results of running static analysis checks when committing changes. report:
Resolves a part of #649
Description
This pull request:
@stdlib/math/base/special/truncbf.The package computes the value of a single-precision floating-point number rounded toward zero to
ndigits in an arbitrary baseb.Implementation Details
Function Signature
Algorithm
The implementation uses the following formula:
It leverages the recently added C implementations of powf (for scaling) and truncf (for truncation) to ensure single-precision accuracy.
Examples
Related Issues
This pull request has the following related issues:
Questions
No.
Other
No.
Checklist
AI Assistance
If you answered "yes" above, how did you use AI assistance?
Disclosure
@stdlib-js/reviewers