Skip to content

Instantly share code, notes, and snippets.

@controlflow
Created March 2, 2020 20:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save controlflow/6e44259f7e737b57750b1d34ac09b7da to your computer and use it in GitHub Desktop.
Save controlflow/6e44259f7e737b57750b1d34ac09b7da to your computer and use it in GitHub Desktop.
public override AbstractValueWithInfo Divide(AbstractValue divisor)
{
switch (divisor)
{
case Scalar otherScalar when (otherScalar.Value == 0):
return AbstractValueWithInfo.DivisionByZero;
case Scalar otherScalar when (otherScalar.Value == 1):
return new AbstractValueWithInfo(this, ErrorType.DivisionByOne);
case Scalar otherScalar:
var result = Divide(myInterval, otherScalar.Value);
return new AbstractValueWithInfo(new Interval(result));
public override AbstractValueWithInfo Divide(AbstractValue divisor)
{
switch (divisor)
{
case Scalar(0):
return AbstractValueWithInfo.DivisionByZero;
case Scalar(1):
return new AbstractValueWithInfo(this, ErrorType.DivisionByOne);
case Scalar(var scalar):
var result = Divide(myInterval, scalar);
return new AbstractValueWithInfo(new Interval(result));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment