Handle NaN in toString().

This commit is contained in:
Michael Bayne
2013-07-26 11:07:02 -07:00
parent 0ff90d641e
commit a46ea711f0
2 changed files with 4 additions and 0 deletions
+2
View File
@@ -196,6 +196,8 @@ public class MathUtil
* The value is also always preceded by a sign (e.g. +1.0 or -0.5).
*/
public static String toString (double value, int decimalPlaces) {
if (Double.isNaN(value)) return "NaN";
StringBuilder buf = new StringBuilder();
if (value >= 0) buf.append("+");
else {
+2
View File
@@ -196,6 +196,8 @@ public class MathUtil
* The value is also always preceded by a sign (e.g. +1.0 or -0.5).
*/
public static String toString (float value, int decimalPlaces) {
if (Float.isNaN(value)) return "NaN";
StringBuilder buf = new StringBuilder();
if (value >= 0) buf.append("+");
else {