min, max, abs support (#201, #206) #216

Merged
sb10q merged 1 commits from min_max_abs into master 2024-08-17 17:37:19 +08:00
Collaborator

Add support for min, max, abs functions.

For abs, previously I thought it would be helpful to make it return unsigned integers, but after checking some more materials, it seems that it is a convention to return signed integers, and most languages like c++/c/java/rust and numpy also returns signed integers. And making abs to return unsigned integers would require having different variant names like abs32, abs64 and absfloat under our type system, so I currently implemented a single abs whose return type is the same as its input type.

Add support for `min`, `max`, `abs` functions. For `abs`, previously I thought it would be helpful to make it return unsigned integers, but after checking some more materials, it seems that it is a convention to return signed integers, and most languages like c++/c/java/rust and numpy also returns signed integers. And making `abs` to return unsigned integers would require having different variant names like `abs32`, `abs64` and `absfloat` under our type system, so I currently implemented a single `abs` whose return type is the same as its input type.
ychenfo added 6 commits 2022-03-08 23:33:41 +08:00
Owner

I don't think the boolean case is very useful or meaningful, but it's not a lot of code and cpython does support it...

I don't think the boolean case is very useful or meaningful, but it's not a lot of code and cpython does support it...
sb10q merged commit 60b3807ab3 into master 2022-03-09 09:04:24 +08:00
sb10q deleted branch min_max_abs 2022-03-09 09:04:25 +08:00
Owner

And thanks for adding comprehensive tests!

And thanks for adding comprehensive tests!
Sign in to join this conversation.
No reviewers
No Milestone
No Assignees
2 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: M-Labs/nac3#216
No description provided.