-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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
coprocessor: add mod(Int/Real/Decimal) RPN functions #4727
Conversation
/run-integration-tests |
Signed-off-by: Lonng <[email protected]>
Signed-off-by: Lonng <[email protected]>
@@ -65,6 +65,15 @@ fn plus_mapper(lhs_is_unsigned: bool, rhs_is_unsigned: bool) -> Box<dyn RpnFunct | |||
} | |||
} | |||
|
|||
fn mod_mapper(lhs_is_unsigned: bool, rhs_is_unsigned: bool) -> Box<dyn RpnFunction> { | |||
match (lhs_is_unsigned, rhs_is_unsigned) { | |||
(false, false) => Box::new(RpnFnArithmetic::<IntIntMod>::new()), |
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.
Maybe we can discover some higher ordered generics to deal with these IntInt, IntUint, UintInt, UintUint later, to reduce code duplicates :) We will have many functions that is different in signed / unsigned integers. Would be too verbose if we need a standalone function for each of them.
Cool! I will click the approve button after resolving comments above. |
Signed-off-by: Lonng <[email protected]>
/run-integration-tests |
/run-integration-tests |
#[test] | ||
fn test_mod_real() { | ||
let tests = vec![ | ||
(Real::new(1.0).ok(), None, None), |
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.
Maybe we can write Option<f64>
here and convert it below in the loop to make the test vec clearer. (I can do it later)
* coprocessor: add mod(Int/Real/Decimal) RPN functions Signed-off-by: Lonng <[email protected]> * remove empty line Signed-off-by: Lonng <[email protected]> * address comment Signed-off-by: Lonng <[email protected]>
* coprocessor: add mod(Int/Real/Decimal) RPN functions Signed-off-by: Lonng <[email protected]> * remove empty line Signed-off-by: Lonng <[email protected]> * address comment Signed-off-by: Lonng <[email protected]>
Signed-off-by: Lonng [email protected]
What have you changed? (mandatory)
Add
mod
(Int/Real/Decimal) RPN functionsWhat are the type of the changes? (mandatory)
How has this PR been tested? (mandatory)
unit tests