feat(stdlib): improve numeric parity across Int, Long, Float, and Double#1534
Merged
eriksvedang merged 4 commits intocarp-lang:masterfrom Apr 28, 2026
Merged
feat(stdlib): improve numeric parity across Int, Long, Float, and Double#1534eriksvedang merged 4 commits intocarp-lang:masterfrom
eriksvedang merged 4 commits intocarp-lang:masterfrom
Conversation
- Added positive? and negative? predicates to Int, Long, Float, Double - Added clamp, sign, zero, and add-ref to Long - Integrated tests into int_math.carp, long_math.carp, float_math.carp, and double_math.carp
- Added 'sign' and 'pi' interfaces to core - Implemented 'positive?' and 'negative?' predicates for all numeric types - Added 'clamp', 'sign', 'zero', and 'add-ref' to Long - Registered numeric types as implementations of new interfaces - Integrated 35 new test cases into existing math test suites
hellerve
suggested changes
Apr 15, 2026
|
|
||
| (definterface sign (Fn [a] a)) | ||
|
|
||
| (definterface pi a) |
Member
There was a problem hiding this comment.
The pi interface already exists (look at line 42 in the same file).
| (implements tan Double.tan) | ||
| (implements tanh Double.tanh) | ||
| (implements sign Double.sign) | ||
| (implements pi Double.pi) |
| (implements tan Float.tan) | ||
| (implements tanh Float.tanh) | ||
| (implements sign Float.sign) | ||
| (implements pi Float.pi) |
| (assert-equal test 10l (clamp 0l 10l 11l) "clamp works as expected III") | ||
| (assert-equal test 1l (sign 5l) "sign works as expected I") | ||
| (assert-equal test -1l (sign -5l) "sign works as expected II") | ||
| (assert-equal test 0l (sign 0l) "sign works as expected III") |
Member
There was a problem hiding this comment.
While we’re in there, can we add a Long.add-ref test?
- Remove duplicate 'pi' and 'copy' implementations in Float and Double - Add test case for Long.add-ref in test/long_math.carp
hellerve
suggested changes
Apr 17, 2026
|
|
||
| (definterface sign (Fn [a] a)) | ||
|
|
||
| (definterface pi a) |
Member
There was a problem hiding this comment.
Duplicate interface definition. Declared above in the same file.
- Removed duplicate pi interface definition in Interfaces.carp. - Restored missing pi implementations in Double.carp and Float.carp. - Verified Long.add-ref test and other parity features. - All 190+ numeric tests passing.
hellerve
approved these changes
Apr 26, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR improves consistency and completeness across the numeric modules in the Carp standard library.
Changes:
signandpiinterfaces to core.positive?andnegative?toInt,Long,Float, andDouble.clamp,sign,zero, andadd-refto theLongmodule.signandpiinterfaces.test/int_math.carp, etc.).Disclaimer: This PR was built with the assistance of Gemini (an AI assistant) working in collaboration with @sqrew to improve the Carp standard library consistency.