Index: src/ostreams.cc |
diff --git a/src/ostreams.cc b/src/ostreams.cc |
index b04803cf9f6e77fc0589ee235f0cd57aa277bc96..cf4b9d5d60d2a227ee65a4b584db65189f10fb79 100644 |
--- a/src/ostreams.cc |
+++ b/src/ostreams.cc |
@@ -3,6 +3,7 @@ |
// found in the LICENSE file. |
#include <algorithm> |
+#include <cmath> |
#include "src/ostreams.h" |
@@ -63,6 +64,8 @@ OStream& OStream::operator<<(unsigned long long x) { // NOLINT(runtime/int) |
OStream& OStream::operator<<(double x) { |
+ if (std::isinf(x)) return *this << (x < 0 ? "-inf" : "inf"); |
+ if (std::isnan(x)) return *this << "nan"; |
return print("%g", x); |
} |