From 99d3c3b1c44848f4738618b4717872a57bb24649 Mon Sep 17 00:00:00 2001 From: "svenpanne@chromium.org" Date: Fri, 11 Jul 2014 12:42:37 +0000 Subject: [PATCH] Made printing of special FP values portable. 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 | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/ostreams.cc b/src/ostreams.cc index b04803c..cf4b9d5 100644 --- a/src/ostreams.cc +++ b/src/ostreams.cc @@ -3,6 +3,7 @@ // found in the LICENSE file. #include +#include #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); } -- 2.7.4