+-NaN and +-Infinity are now correctly represented in Trick View. (#437)

* Values that return "-nan" will now properly show <NaN> in the Trick View variable table.

* +-NaN and +-Infinity are now correctly represented in Trick View.

This solution now handles +- infinity and +-nan instead of just -nan.

* Lifted fix logic into a protected function in the super class.

Removed author/date information.
Put duplicate code from VSFLoat and VSDouble into VSValue.
Added support for -NaN.
This commit is contained in:
Christopher LaChance 2017-06-08 12:09:39 -05:00 committed by GitHub
parent 6c73951488
commit 8fb1355de3
3 changed files with 17 additions and 3 deletions

View File

@ -12,7 +12,7 @@ public class VSDouble extends VSValue<Double> {
@Override
public void fromVariableServer(String string) {
setValue(Double.parseDouble(string.trim()));
setValue(Double.parseDouble(handleUndefinedValues(string).trim()));
}
@Override

View File

@ -12,7 +12,6 @@ public class VSFloat extends VSValue<Float> {
@Override
public void fromVariableServer(String string) {
setValue(Float.parseFloat(string.trim()));
setValue(Float.parseFloat(handleUndefinedValues(string).trim()));
}
}

View File

@ -44,4 +44,19 @@ public abstract class VSValue<T> implements VariableServerFluent, Cloneable {
}
}
protected String handleUndefinedValues(String input) {
if(input.equals("inf")) {
input = "Infinity";
}
else if(input.equals("-inf")) {
input = "-Infinity";
}
else if(input.equals("nan")) {
input = "NaN";
}
else if(input.equals("-nan")) {
input = "-NaN";
}
return input;
}
}