-
Notifications
You must be signed in to change notification settings - Fork 165
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
feat: add options for behaviour when dividing by zero or calculating log zero #329
Conversation
extensions/functions_arithmetic.yaml
Outdated
description: > | ||
Divide x by y. In the case of integer division, partial values are truncated. | ||
The `on_division_by_zero` option governs behaviour in cases where y is 0 and x is not 0. | ||
The `on_domain_error` option governs behaviour for 0/0 and Inf/Inf etc. |
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.
Not sure if this is quite right?
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.
It looks fine to me, but cc @pitrou
ETA: actually, the order should probably be LIMIT
, NAN
, and then ERROR
, because LIMIT
makes the most sense. We should probably specify what LIMIT
means, too (i.e. +/- infinity based on sign of numerator and signed zero denominator).
PS. I honestly can't tell if github actually added this comment when I first reviewed this because the UI was glitching all to hell, but it seems to be missing for me now, so... Please excuse me if this ends up being duplicated.
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.
That makes sense, updated now!
d79e06c
to
6475119
Compare
extensions/functions_arithmetic.yaml
Outdated
@@ -175,7 +175,10 @@ scalar_functions: | |||
return: fp64 | |||
- | |||
name: "divide" | |||
description: "Divide one value by another. Partial values are truncated." | |||
description: > | |||
Divide x by y. In the case of integer division, partial values are truncated. |
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.
Can we describe more precisely what "partial values are truncated" means? (truncated towards zero, or truncated towards minus infinity - i.e. floored?)
For example, what would be the result of 1 / -3
?
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.
+1, we use "truncation" for rounding toward zero (in contrast with ceil for +infinity and floor for -infinity) but it bears repeating.
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 have not seen truncation defined before as anything other than "round towards zero", but adding a few extra words does no harm, so updated here.
73dc099
to
c0624ec
Compare
c0624ec
to
65bb17a
Compare
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 now, thanks!
This PR adds options which allow specification of behaviour when dividing by 0 or when trying to calculate log of 0. See discussion on #302 for more detail.