add additional comments
This commit is contained in:
parent
66a4c06a9d
commit
bc53b798e6
@ -8903,19 +8903,24 @@ skip_loop:
|
|||||||
{1.e1L, 1.e2L, 1.e4L, 1.e8L, 1.e16L, 1.e32L, 1.e64L, 1.e128L, 1.e256L}
|
{1.e1L, 1.e2L, 1.e4L, 1.e8L, 1.e16L, 1.e32L, 1.e64L, 1.e128L, 1.e256L}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// round to INF if our exponent is larger than representable number
|
||||||
if (exp > std::numeric_limits<long double>::max_exponent10)
|
if (exp > std::numeric_limits<long double>::max_exponent10)
|
||||||
{
|
{
|
||||||
constexpr long double inf = std::numeric_limits<long double>::infinity();
|
constexpr long double inf = std::numeric_limits<long double>::infinity();
|
||||||
result = (result < 0) ? -inf : inf;
|
result = (result < 0) ? -inf : inf;
|
||||||
}
|
}
|
||||||
|
// round to zero if our exponent is smaller than representable number
|
||||||
else if (exp < std::numeric_limits<long double>::min_exponent10)
|
else if (exp < std::numeric_limits<long double>::min_exponent10)
|
||||||
{
|
{
|
||||||
result = 0.0L;
|
result = 0.0L;
|
||||||
}
|
}
|
||||||
|
// iteratively divide result for negative exp
|
||||||
else if (exp < 0)
|
else if (exp < 0)
|
||||||
{
|
{
|
||||||
|
// make exp positive for loop below
|
||||||
exp *= -1;
|
exp *= -1;
|
||||||
|
|
||||||
|
// check enabled exp bits on lookup powerof10 lookup table
|
||||||
for (std::size_t count = 0; exp; ++count, exp >>= 1)
|
for (std::size_t count = 0; exp; ++count, exp >>= 1)
|
||||||
{
|
{
|
||||||
if (exp & 1)
|
if (exp & 1)
|
||||||
@ -8924,8 +8929,10 @@ skip_loop:
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
// iteratively multiply result for positive exp
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
// check enabled exp bits on lookup powerof10 lookup table
|
||||||
for (std::size_t count = 0; exp; ++count, exp >>= 1)
|
for (std::size_t count = 0; exp; ++count, exp >>= 1)
|
||||||
{
|
{
|
||||||
if (exp & 1)
|
if (exp & 1)
|
||||||
|
|||||||
@ -8200,19 +8200,24 @@ skip_loop:
|
|||||||
{1.e1L, 1.e2L, 1.e4L, 1.e8L, 1.e16L, 1.e32L, 1.e64L, 1.e128L, 1.e256L}
|
{1.e1L, 1.e2L, 1.e4L, 1.e8L, 1.e16L, 1.e32L, 1.e64L, 1.e128L, 1.e256L}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// round to INF if our exponent is larger than representable number
|
||||||
if (exp > std::numeric_limits<long double>::max_exponent10)
|
if (exp > std::numeric_limits<long double>::max_exponent10)
|
||||||
{
|
{
|
||||||
constexpr long double inf = std::numeric_limits<long double>::infinity();
|
constexpr long double inf = std::numeric_limits<long double>::infinity();
|
||||||
result = (result < 0) ? -inf : inf;
|
result = (result < 0) ? -inf : inf;
|
||||||
}
|
}
|
||||||
|
// round to zero if our exponent is smaller than representable number
|
||||||
else if (exp < std::numeric_limits<long double>::min_exponent10)
|
else if (exp < std::numeric_limits<long double>::min_exponent10)
|
||||||
{
|
{
|
||||||
result = 0.0L;
|
result = 0.0L;
|
||||||
}
|
}
|
||||||
|
// iteratively divide result for negative exp
|
||||||
else if (exp < 0)
|
else if (exp < 0)
|
||||||
{
|
{
|
||||||
|
// make exp positive for loop below
|
||||||
exp *= -1;
|
exp *= -1;
|
||||||
|
|
||||||
|
// check enabled exp bits on lookup powerof10 lookup table
|
||||||
for (std::size_t count = 0; exp; ++count, exp >>= 1)
|
for (std::size_t count = 0; exp; ++count, exp >>= 1)
|
||||||
{
|
{
|
||||||
if (exp & 1)
|
if (exp & 1)
|
||||||
@ -8221,8 +8226,10 @@ skip_loop:
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
// iteratively multiply result for positive exp
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
// check enabled exp bits on lookup powerof10 lookup table
|
||||||
for (std::size_t count = 0; exp; ++count, exp >>= 1)
|
for (std::size_t count = 0; exp; ++count, exp >>= 1)
|
||||||
{
|
{
|
||||||
if (exp & 1)
|
if (exp & 1)
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user