Skip to content
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

change return value of divide function if denominator is zero #9485

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

rcichota
Copy link
Contributor

@rcichota rcichota commented Dec 1, 2024

Resolves #9484
Returning the maximum value for double for the cases when denominator of the divide function is zero. This should be much more sensible and don't break expectations for users (not too much at least). The current return of zero is just not right.

@rcichota
Copy link
Contributor Author

rcichota commented Dec 1, 2024

Retest this please Jenkins

@hut104
Copy link
Contributor

hut104 commented Dec 1, 2024

A few comments.

  1. What if the first value is zero? what is zero/zero?
  2. What if you have three values? 1/0/0.5 I think this will still return zero because the first dived with give double.maxvalue and the second divide will return zero again.

@rcichota
Copy link
Contributor Author

rcichota commented Dec 1, 2024

Good questions Neil
There probably should be a catch and return error if zero/zero (or maybe even any division by zero). But it seems this will break a few simulations... Not sure what to do about them.
However, if a value is to be returned, I think that returning MaxValue is less problematic (less 'wrong') than returning zero.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Divide function returning zero when denominator is zero
2 participants