Permalink
Browse files

Four4Sample - redefine square root to be invalid for 0 & 1

  • Loading branch information...
bobbymcr committed Mar 11, 2018
1 parent d5ba4bb commit 8acf697274335bf671f4333a421323fc50208bf3
Showing with 4 additions and 2 deletions.
  1. +3 −1 projects/Four4Sample/Four4.Test/EvalTest.cs
  2. +1 −1 projects/Four4Sample/Four4/Number.cs
@@ -108,14 +108,16 @@ public void Factorial(string input, string result)
[InlineData("4 4 + R", "NaN")]
[InlineData(".4 .4_ / R", "NaN")]
[InlineData(".4 .4_ / R R", "NaN")]
[InlineData("4 4 - R R", "0")]
[InlineData("4 4 - R R", "NaN")]
[InlineData("4 4 - 4 - R", "NaN")]
[InlineData("4 4 - .4_ - R", "NaN")]
[InlineData("R", "NaN")]
[InlineData("4 4 R", "NaN")]
[InlineData("4 R R", "NaN")]
[InlineData("4 R R R", "NaN")]
[InlineData("4 4 4 R R R R", "NaN")]
[InlineData("4 4 - R", "NaN")]
[InlineData("4 4 / R", "NaN")]
public void SquareRoot(string input, string result)
{
Test(input, result);
@@ -106,7 +106,7 @@ public Number Factorial()
public Number SquareRoot()
{
if (this.denom == 0)
if ((this.num <= 0) || ((this.num == 1) && (this.denom == 1)))
{
return NaN;
}

0 comments on commit 8acf697

Please sign in to comment.