Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(211)

Unified Diff: src/ostreams.cc

Issue 386973003: Made printing of special FP values portable. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 6 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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);
}
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698