@@ -291,23 +291,17 @@ simdjson_really_inline bool compute_float_64(int64_t power, uint64_t i, bool neg
291
291
// one digit.
292
292
static bool parse_float_fallback (const uint8_t *ptr, double *outDouble) {
293
293
*outDouble = simdjson::internal::from_chars ((const char *)ptr);
294
- // We do not accept infinite values. Detecting finite values in a portable manner is ridiculously hard.
295
- //
296
- // Next line would be nice but if fails under Visual Studio with error C2589: '(': illegal token on right side of '::'
297
- // despite the fact that we have '#include <limits>' above.
298
- // if ((*outDouble > std::numeric_limits<double>::max()) || (*outDouble < std::numeric_limits<double>::lowest())) {
299
- //
300
- // Next line would be better but it mysteriously fails under legacy/old libc++ libraries.
301
- // See https://github.com/simdjson/simdjson/issues/1286
302
- // if (!std::isfinite(*outDouble)) {
303
- //
304
- // So we use the following that ought to work under all systems.
305
- // (Note that I also tried hexadecimal floats but it failed under some systems too.)
294
+ // We do not accept infinite values.
295
+
296
+ // Detecting finite values in a portable manner is ridiculously hard, ideally
297
+ // we would want to do:
298
+ // return !std::isfinite(*outDouble);
299
+ // but that mysteriously fails under legacy/old libc++ libraries, see
300
+ // https://github.com/simdjson/simdjson/issues/1286
306
301
//
307
- if ((*outDouble > 1.7976931348623157E+308 ) || (*outDouble < -1.7976931348623157E+308 )) {
308
- return false ;
309
- }
310
- return true ;
302
+ // Therefore, fall back to this solution (the extra parens are there
303
+ // to handle that max may be a macro on windows).
304
+ return !(*outDouble > (std::numeric_limits<double >::max)() || *outDouble < std::numeric_limits<double >::lowest ());
311
305
}
312
306
313
307
// check quickly whether the next 8 chars are made of digits
0 commit comments