Made printing of special FP values portable.
authorsvenpanne@chromium.org <svenpanne@chromium.org@ce2b1a6d-e550-0410-aec6-3dcde31c8c00>
Fri, 11 Jul 2014 12:42:37 +0000 (12:42 +0000)
committersvenpanne@chromium.org <svenpanne@chromium.org@ce2b1a6d-e550-0410-aec6-3dcde31c8c00>
Fri, 11 Jul 2014 12:42:37 +0000 (12:42 +0000)
R=mstarzinger@chromium.org

Review URL: https://codereview.chromium.org/386973003

git-svn-id: https://v8.googlecode.com/svn/branches/bleeding_edge@22354 ce2b1a6d-e550-0410-aec6-3dcde31c8c00

src/ostreams.cc

index b04803c..cf4b9d5 100644 (file)
@@ -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);
 }