FormatDouble static method

String FormatDouble(
  1. double value
)

Formats a double like .NET's invariant culture ("1" rather than "1.0").

Implementation

static String FormatDouble(double value) {
  if (value.isNaN) {
    return "NaN";
  } else if (value.isInfinite) {
    return value > 0 ? "Infinity" : "-Infinity";
  } else if (value == value.truncateToDouble() && value.abs() < 1e15) {
    return value.toStringAsFixed(0);
  } else {
    return value.toString();
  }
}