handle NaN

This commit is contained in:
Denis Molony 2016-07-21 21:08:28 +10:00
parent 1ee6cf4115
commit 0ee07d662a
3 changed files with 5 additions and 1 deletions

View File

@ -125,6 +125,8 @@ class Cell implements Comparable<Cell>, Value
return justify (value.getText (), colWidth); return justify (value.getText (), colWidth);
Double thisValue = value.getValue (); Double thisValue = value.getValue ();
if (thisValue.isNaN ())
return justify ("NaN", colWidth);
char format = cellFormat != ' ' ? cellFormat : defaultFormat; char format = cellFormat != ' ' ? cellFormat : defaultFormat;
if (format == 'I') if (format == 'I')
@ -213,7 +215,7 @@ class Cell implements Comparable<Cell>, Value
{ {
if (!isValue ()) if (!isValue ())
{ {
// System.out.println ("Not a value"); // System.out.println (value);
return this; return this;
} }
assert isValue () : "Cell type: " + type + " @ " + address; assert isValue () : "Cell type: " + type + " @ " + address;

View File

@ -31,6 +31,7 @@ class Count extends Function
if (cell.getValue () != 0.0) if (cell.getValue () != 0.0)
value++; value++;
} }
return this; return this;
} }
} }

View File

@ -272,6 +272,7 @@ class Expression implements Value
else if (text.charAt (ptr) == '(') else if (text.charAt (ptr) == '(')
++depth; ++depth;
} }
return text.substring (0, ptr + 1); // include closing parenthesis return text.substring (0, ptr + 1); // include closing parenthesis
} }