diff --git a/include/simdjson/generic/numberparsing.h b/include/simdjson/generic/numberparsing.h index 771504bca..e0b1fa5fd 100644 --- a/include/simdjson/generic/numberparsing.h +++ b/include/simdjson/generic/numberparsing.h @@ -292,8 +292,9 @@ simdjson_really_inline bool compute_float_64(int64_t power, uint64_t i, bool neg // one digit. static bool parse_float_fallback(const uint8_t *ptr, double *outDouble) { *outDouble = simdjson::internal::from_chars((const char *)ptr); - // We do not accept infinite values. - if (!std::isfinite(*outDouble)) { + // We do not accept infinite values. Yes, there is a std::isfinite function, but + // it appears to be broken in legacy libc++. + if ((*outDouble > 0x1.fffffffffffffp+1023) || (*outDouble < -0x1.fffffffffffffp+1023)) { return false; } return true; diff --git a/src/to_chars.cpp b/src/to_chars.cpp index 45aa12cba..9860c9634 100644 --- a/src/to_chars.cpp +++ b/src/to_chars.cpp @@ -914,8 +914,13 @@ format. Returns an iterator pointing past-the-end of the decimal representation. */ char *to_chars(char *first, const char *last, double value) { static_cast(last); // maybe unused - fix warning - // Use signbit(value) instead of (value < 0) since signbit works for -0. - if (std::signbit(value)) { + // It would be better to use signbit(value) instead of (value < 0) since signbit works for -0. + //if(std::signbit(value)) { + // value = -value; + // *first++ = '-'; + //} + // However, under older libc++, std::signbit causes build errors, so falling back: + if((value < 0) || (value == -0)){ value = -value; *first++ = '-'; }