-
Notifications
You must be signed in to change notification settings - Fork 16
fix: Improve ergonomics for the Decimal type #341
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
fix: Improve ergonomics for the Decimal type #341
Conversation
domoritz
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- Comprehensive tests for isNegativeDecimal, negateDecimal - Tests for toDecimalString and toDecimalNumber conversions - Tests for fromDecimalString parsing with roundtrips - Integration tests for negation and edge cases
|
Thanks for these utilities. I think we should try to use them in the default converters so that #77 gets fixed. Either you could do this here or we can do it in a follow up when you fixed the CI errors and we merged. |
I have fixed CI error can you merge it. |
|
Could you check lint failures? https://github.com/apache/arrow-js/actions/runs/19644239168/job/56300291328?pr=341#step:5:8 FYI: You can run CI on your fork by enabling GitHub Actions on your fork. |
- Change 'let n' to 'const n' (prefer-const) - Use ternary for magnitude assignment (unicorn/prefer-ternary) - Use ternary for result composition (unicorn/prefer-ternary)
I have fix this can you merge it. |
| } | ||
|
|
||
| // Calculate divisor as 10^scale | ||
| // Using a loop instead of BigInt exponentiation (**) for ES2015 compatibility |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we bump to something beyond es2015 for better code?
What's Changed
Added a new decimal.ts module that provides high-level utilities for working with Decimal128 and Decimal256 values in JavaScript. These utilities make decimal handling more ergonomic by removing the need for low-level bit manipulation and aligning behavior with Arrow C++ semantics. The module is exported through the util namespace and integrates cleanly without introducing breaking changes.
Closes #81.