Permalink
Browse files

Four4Sample - Handle "underflow" of numerator in multiply

  • Loading branch information...
bobbymcr committed Mar 17, 2018
1 parent 7229bdb commit e8ffde36f02f62ecc141e9e16bffef890918e1b0
Showing with 2 additions and 1 deletion.
  1. +1 −0 projects/Four4Sample/Four4.Test/EvalTest.cs
  2. +1 −1 projects/Four4Sample/Four4/Number.cs
@@ -161,6 +161,7 @@ public void Exponent(string input, string result)
[InlineData("3 ! ! 3 ^", "373248000")]
[InlineData("3 ! ! 3 ^ .3 /", "NaN")]
[InlineData("3 ! ! 3 ^ .3 / 3 ^", "NaN")]
[InlineData("3 ! ! 3 ^ .3 33 - /", "NaN")]
public void ExpressionsWith3(string input, string result)
{
Test(input, result);
@@ -62,7 +62,7 @@ public Number(int num, int denom)
public static Number operator *(Number left, Number right)
{
double nr = (double)left.num * right.num;
if (nr > int.MaxValue)
if ((nr > int.MaxValue) || (nr < int.MinValue))
{
return NaN;
}

0 comments on commit e8ffde3

Please sign in to comment.