diff --git a/src/com/bytezone/diskbrowser/visicalc/Cell.java b/src/com/bytezone/diskbrowser/visicalc/Cell.java index a41ffe9..d6cbfc6 100644 --- a/src/com/bytezone/diskbrowser/visicalc/Cell.java +++ b/src/com/bytezone/diskbrowser/visicalc/Cell.java @@ -121,12 +121,10 @@ class Cell implements Comparable, Value return justify (repeat, colWidth); case VALUE: - if (value.isError () || value.isNotAvailable ()) + if (value.isError () || value.isNotAvailable () || value.isNotANumber ()) return justify (value.getText (), colWidth); Double thisValue = value.getValue (); - if (thisValue.isNaN ()) - return justify ("NaN", colWidth); char format = cellFormat != ' ' ? cellFormat : defaultFormat; if (format == 'I') @@ -210,6 +208,15 @@ class Cell implements Comparable, Value return value.isNotAvailable (); } + @Override + public boolean isNotANumber () + { + // assert type == CellType.VALUE : "Cell type: " + type; + // if (!isValue ()) + // return true; + return value.isNotANumber (); + } + @Override public Value calculate () { diff --git a/src/com/bytezone/diskbrowser/visicalc/Expression.java b/src/com/bytezone/diskbrowser/visicalc/Expression.java index 18b45da..9fe21cb 100644 --- a/src/com/bytezone/diskbrowser/visicalc/Expression.java +++ b/src/com/bytezone/diskbrowser/visicalc/Expression.java @@ -173,7 +173,11 @@ class Expression implements Value else if (operator.equals ("^")) value = Math.pow (value, nextValue); } - valueType = ValueType.VALUE; + + if (Double.isNaN (value)) + valueType = ValueType.NAN; + else + valueType = ValueType.VALUE; } catch (Exception e) { @@ -202,6 +206,12 @@ class Expression implements Value return valueType == ValueType.NA; } + @Override + public boolean isNotANumber () + { + return valueType == ValueType.NAN; + } + @Override public boolean isError () { @@ -211,14 +221,15 @@ class Expression implements Value @Override public double getValue () { - assert valueType == ValueType.VALUE : "Expression ValueType = " + valueType; + // assert valueType == ValueType.VALUE : "Expression ValueType = " + valueType; return value; } @Override public String getText () { - return isNotAvailable () ? "NA" : isError () ? "Error" : ""; + return isNotAvailable () ? "NA" : isError () ? "Error" : isNotANumber () ? "NaN" : ""; + // return isNotAvailable () ? "NA" : isError () ? "Error" : ""; } private String checkBrackets (String input) diff --git a/src/com/bytezone/diskbrowser/visicalc/Function.java b/src/com/bytezone/diskbrowser/visicalc/Function.java index ad94988..762c3b0 100644 --- a/src/com/bytezone/diskbrowser/visicalc/Function.java +++ b/src/com/bytezone/diskbrowser/visicalc/Function.java @@ -139,6 +139,12 @@ abstract class Function implements Value return valueType == ValueType.NA; } + @Override + public boolean isNotANumber () + { + return valueType == ValueType.NAN; + } + @Override public double getValue () { @@ -150,7 +156,7 @@ abstract class Function implements Value @Override public String getText () { - return isNotAvailable () ? "" : isError () ? "Error" : ""; + return isNotAvailable () ? "NA" : isError () ? "Error" : isNotANumber () ? "NaN" : ""; } protected Range getRange (String text) diff --git a/src/com/bytezone/diskbrowser/visicalc/Number.java b/src/com/bytezone/diskbrowser/visicalc/Number.java index b0fcaac..aa4ac49 100644 --- a/src/com/bytezone/diskbrowser/visicalc/Number.java +++ b/src/com/bytezone/diskbrowser/visicalc/Number.java @@ -36,6 +36,12 @@ class Number implements Value return valueType == ValueType.NA; } + @Override + public boolean isNotANumber () + { + return valueType == ValueType.NAN; + } + @Override public String toString () { @@ -51,7 +57,8 @@ class Number implements Value @Override public String getText () { - return valueType == ValueType.ERROR ? "Error" : ""; + return isNotAvailable () ? "NA" : isError () ? "Error" : isNotANumber () ? "NaN" : ""; + // return valueType == ValueType.ERROR ? "Error" : ""; } @Override diff --git a/src/com/bytezone/diskbrowser/visicalc/Value.java b/src/com/bytezone/diskbrowser/visicalc/Value.java index fccac5e..50fac61 100644 --- a/src/com/bytezone/diskbrowser/visicalc/Value.java +++ b/src/com/bytezone/diskbrowser/visicalc/Value.java @@ -4,7 +4,7 @@ interface Value { enum ValueType { - VALUE, ERROR, NA + VALUE, ERROR, NA, NAN } public ValueType getValueType (); @@ -19,5 +19,7 @@ interface Value public boolean isNotAvailable (); + public boolean isNotANumber (); + public Value calculate (); } \ No newline at end of file