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

Don't allow dividing by 0 #29

Open
evykassirer opened this issue Dec 12, 2016 · 11 comments
Open

Don't allow dividing by 0 #29

evykassirer opened this issue Dec 12, 2016 · 11 comments

Comments

@evykassirer
Copy link
Contributor

evykassirer commented Dec 12, 2016

This is blocked on our error infrastruction #129 -- let's use it as the first error that we implement with the new error structure


We don't check for this, which means division by 0 gives weird results.

This functionality would probably go in simplifyBasics, or in a separate DFS before that - since checking for dividing by zero is important before anything else is attempted.

I think (though feel free to approach this a different way) that dividing by zero would look like this:

  • the divide by 0 function returns a NodeStatus.hasChanged object where newNode is actually the same as oldNode and the changeType is DIVIDE_BY_ZERO
  • in simplifyExpression, in the function stepThrough, after each call to step, check if the changeType was DIVIDE_BY_ZERO -- if so, break out of the while loop
@hmaurer
Copy link
Contributor

hmaurer commented Jan 20, 2017

I am on this; will PR soon. How should we handle the 0/0 case? Return DIVIDE_BY_ZERO too?

@evykassirer
Copy link
Contributor Author

yeah, I think I'm comfy having them give the same error. Sound ok to you?

@hmaurer
Copy link
Contributor

hmaurer commented Jan 20, 2017

Yes I think that makes sense! I'll PR later tonight.

@evykassirer
Copy link
Contributor Author

Hey @hmaurer, I see you have a branch open for this and a commit - did you forget to put up a PR or did you want to work on it a bit more first?

@evykassirer
Copy link
Contributor Author

@hmaurer ?

@hmaurer
Copy link
Contributor

hmaurer commented Jan 25, 2017

@evykassirer Sorry for the delay; I have opened a PR

edit: will do in 5min, I first need to merge master and there are conflicts :(

@evykassirer
Copy link
Contributor Author

no problem at all, just wanted to make sure it wasn't forgotten about ^_^

@aelnaiem
Copy link
Collaborator

This is interesting, I wonder if there should be a NodeStatus for errors like this in general that we check, not just divide by zero.

@evykassirer
Copy link
Contributor Author

@aelnaiem I was thinking about that too!

In the PR, I talked about:

oh, maybe a nodeStatus should have both a changeType and an errorType (default to null)? idk, still trying to figure out what this would look like long term

what do you think?

@aelnaiem
Copy link
Collaborator

aelnaiem commented Feb 1, 2017

Yea I think that's a good idea!

@evykassirer
Copy link
Contributor Author

UPDATE: now related to #129 -- let's use it as the first error that we implement with the new error structure

I removed the small label, since this is more complicated now

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

No branches or pull requests

3 participants