Skip to content

Instantly share code, notes, and snippets.

@controlflow
Last active November 28, 2016 21:16
Show Gist options
  • Select an option

  • Save controlflow/5a6d672263cf298483b45bc1bf380f2c to your computer and use it in GitHub Desktop.

Select an option

Save controlflow/5a6d672263cf298483b45bc1bf380f2c to your computer and use it in GitHub Desktop.
[Pure]
private static bool IsNegativeInfinity([NotNull] ICSharpExpression expression)
{
var constantValue = expression.ConstantValue.Value;
if (constantValue is double)
return double.IsNegativeInfinity((double) constantValue);
if (constantValue is float)
return float.IsNegativeInfinity((float) constantValue);
return false;
}
[Pure]
private static bool IsNegativeInfinity([NotNull] ICSharpExpression expression)
{
switch (expression.ConstantValue.Value)
{
case double x:
return double.IsNegativeInfinity(x);
case float x:
return float.IsNegativeInfinity(x);
default:
return false;
}
}
[Pure]
private static bool IsNegativeInfinity([NotNull] ICSharpExpression expression) =>
match (expression.ConstantValue.Value)
{
case double x => double.IsNegativeInfinity(x);
case float x => float.IsNegativeInfinity(x);
default => false;
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment