tinyexpr: Check for nan in ncr

Turns out this takes ages.

Fixes #8170
This commit is contained in:
Fabian Homborg
2021-07-26 18:39:09 +02:00
parent 4bb1c72a91
commit d32e1c12be
2 changed files with 8 additions and 0 deletions

View File

@@ -156,6 +156,8 @@ static double fac(double a) { /* simplest version of fac */
}
static double ncr(double n, double r) {
// Doing this for NAN takes ages - just return the result right away.
if (std::isnan(n)) return INFINITY;
if (n < 0.0 || r < 0.0 || n < r) return NAN;
if (n > UINT_MAX || r > UINT_MAX) return INFINITY;
unsigned long int un = static_cast<unsigned int>(n), ur = static_cast<unsigned int>(r), i;