Merge pull request #1927 from JoePfeiffer/display-NaN-as-N/A

Display nan as n/a
This commit is contained in:
Sibo Van Gool 2022-12-27 12:07:23 +01:00 committed by GitHub
commit e9064dc759
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 10 additions and 2 deletions

View File

@ -90,8 +90,11 @@ public abstract class Unit {
* @return A string representation of the number in these units. * @return A string representation of the number in these units.
*/ */
public String toString(double value) { public String toString(double value) {
double val = toUnit(value); if (Double.isNaN(value))
return "N/A";
double val = toUnit(value);
if (Math.abs(val) > 1E6) { if (Math.abs(val) > 1E6) {
return expFormat.format(val); return expFormat.format(val);
} }

View File

@ -571,7 +571,12 @@ public class ComponentAnalysisDialog extends JDialog implements StateChangeListe
} }
if (forces.getCP() != null) { if (forces.getCP() != null) {
row.cpx = forces.getCP().x; if ((comp instanceof Rocket) &&
(forces.getCP().weight < MathUtil.EPSILON)) {
row.cpx = Double.NaN;
} else {
row.cpx = forces.getCP().x;
}
row.cna = forces.getCNa(); row.cna = forces.getCNa();
} }