Fixing build errors under legacy libc++.

This commit is contained in:
Daniel Lemire
2020-11-03 21:57:23 -05:00
parent 6a86ef5a7d
commit 80db053be3
2 changed files with 10 additions and 4 deletions
+3 -2
View File
@@ -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;
+7 -2
View File
@@ -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<void>(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++ = '-';
}