mirror of
https://github.com/simdjson/simdjson
synced 2026-06-08 17:27:07 +00:00
Fixing build errors under legacy libc++.
This commit is contained in:
@@ -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
@@ -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++ = '-';
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user