X-Git-Url: http://plrg.eecs.uci.edu/git/?p=folly.git;a=blobdiff_plain;f=folly%2FConv.h;h=17b2fc67df434ba177755f78e3dd5ea0703cd692;hp=20cf3d51b2fe84c208014bf30732e129a211c95a;hb=a110f8daa0ad5cca47c5be85cb415d0cd3bd3f57;hpb=01de3b4373aee3e7f53c0b469fb8d50d71b87b35 diff --git a/folly/Conv.h b/folly/Conv.h index 20cf3d51..17b2fc67 100644 --- a/folly/Conv.h +++ b/folly/Conv.h @@ -557,8 +557,11 @@ toAppend(Src value, Tgt * result) { char buffer[20]; if (value < 0) { result->push_back('-'); + using u = std::make_signed::type; result->append( - buffer, uint64ToBufferUnsafe(uint64_t(-uint64_t(value)), buffer)); + buffer, + uint64ToBufferUnsafe( + static_cast(-static_cast(value)), buffer)); } else { result->append(buffer, uint64ToBufferUnsafe(uint64_t(value), buffer)); } @@ -1179,13 +1182,14 @@ parseTo(StringPiece src, Tgt& out) { namespace detail { /** - * Bool to integral doesn't need any special checks, and this + * Bool to integral/float doesn't need any special checks, and this * overload means we aren't trying to see if a bool is less than * an integer. */ template typename std::enable_if< - !std::is_same::value && std::is_integral::value, + !std::is_same::value && + (std::is_integral::value || std::is_floating_point::value), Expected>::type convertTo(const bool& value) noexcept { return static_cast(value ? 1 : 0);