mirror of
https://github.com/nasa/trick.git
synced 2025-04-13 22:23:11 +00:00
+-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:
parent
6c73951488
commit
8fb1355de3
@ -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
|
||||
|
@ -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()));
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user