-
Notifications
You must be signed in to change notification settings - Fork 323
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
Decimal remainder, pow, div #9566
Conversation
Remainder in Enso will undergo automatic conversions such that you need | ||
not convert other numeric types to `Decimal` manually. |
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.
This sounds to me like the result of the operation will undergo conversions, which as far as I understand is not the case and you mean the arguments, right?
Maybe we can rephrase it to make it clearer?
Remainder in Enso will undergo automatic conversions such that you need | |
not convert other numeric types to `Decimal` manually. | |
Arguments of the `remainder` operation will undergo automatic conversions such that you need | |
not convert other numeric types to `Decimal` manually. |
maybe something like that?
- I don't think you need to say
in Enso
there - this is an Enso library so that is rather assumed, - IMO it's good to point you mean arguments
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.
Done.
+ [[5, 3, 2], [5.0, 3.0, 2.0], [3.5, 2, 1.5], [10.5, 1.0, 0.5], [3, 1, 0], [3.0, 1.0, 0]] | ||
+ [[-5, 3, -2], [-5.0, 3.0, -2.0], [-3.5, 2, -1.5], [-10.5, 1.0, -0.5], [-3, 1, 0], [-3.0, 1.0, 0]] | ||
+ [["9223372036854775807", 10, 7], ["9223372036854775808", 10, 8], ["922337203685477580000000000008", 10, 8]] | ||
+ [["-9223372036854775808", 10, -8], ["-9223372036854775809", 10, -9], ["-922337203685477580000000000008", 10, -8]] | ||
cases.map c-> | ||
base = c.at 0 | ||
modulus = c.at 1 | ||
residue = c.at 2 | ||
(Decimal.new base % modulus) . should_equal residue | ||
(Decimal.new base % Decimal.new modulus) . should_equal residue |
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.
I'd probably add a test case for something like 2.7 % 0.5
. Should it work and return 0.2
or are non-integer arguments not allowed? Either way it would be good to have a test.
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.
Done.
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.
Looks good, just some small comments
Checklist
Please ensure that the following checklist has been satisfied before submitting the PR:
Scala,
Java,
and
Rust
style guides. In case you are using a language not listed above, follow the Rust style guide.
./run ide build
.