Skip to content

Commit

Permalink
Four4Sample - Handle "underflow" of numerator in multiply
Browse files Browse the repository at this point in the history
  • Loading branch information
bobbymcr committed Mar 17, 2018
1 parent 7229bdb commit e8ffde3
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 1 deletion.
1 change: 1 addition & 0 deletions projects/Four4Sample/Four4.Test/EvalTest.cs
Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion projects/Four4Sample/Four4/Number.cs
Expand Up @@ -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;
}
Expand Down

0 comments on commit e8ffde3

Please sign in to comment.