convertDoubleTo: invert the condition so we catch NaNs early

This is floating point, so De Morgan doesn't always apply.

Change-Id: I89446ea06b5742efb194fffd16bb9e36025cb387
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
This commit is contained in:
Thiago Macieira 2021-11-27 21:20:44 -08:00
parent 0ca6ad8cfc
commit 1ee875dcac

View File

@ -198,7 +198,7 @@ static inline bool convertDoubleTo(double v, T *value, bool allow_precision_upgr
// T has more bits than double's mantissa, so don't allow "upgrading"
// to T (makes it look like the number had more precision than really
// was transmitted)
if (!allow_precision_upgrade && (v > double(max_mantissa) || v < double(-max_mantissa - 1)))
if (!allow_precision_upgrade && !(v <= double(max_mantissa) && v >= double(-max_mantissa - 1)))
return false;
}