remove unneeded branch

This commit is contained in:
Jett 2016-10-20 23:59:02 -05:00
parent 7cc60ccc0a
commit dec60cb66a
2 changed files with 48 additions and 54 deletions

View File

@ -8900,41 +8900,38 @@ skip_loop:
} }
// adjust number by powers of ten specified by format and exponent. // adjust number by powers of ten specified by format and exponent.
if (result != 0.0L) constexpr std::array<long double, 9> powerof10 = {
{1.e1L, 1.e2L, 1.e4L, 1.e8L, 1.e16L, 1.e32L, 1.e64L, 1.e128L, 1.e256L}
};
if (exp > std::numeric_limits<long double>::max_exponent10)
{ {
constexpr std::array<long double, 9> powerof10 = { constexpr long double inf = std::numeric_limits<long double>::infinity();
{1.e1L, 1.e2L, 1.e4L, 1.e8L, 1.e16L, 1.e32L, 1.e64L, 1.e128L, 1.e256L} result = (result < 0) ? -inf : inf;
}; }
else if (exp < std::numeric_limits<long double>::min_exponent10)
{
result = 0.0L;
}
else if (exp < 0)
{
exp = -exp;
if (exp > std::numeric_limits<long double>::max_exponent10) for (std::size_t count = 0; exp; ++count, exp >>= 1)
{ {
constexpr long double inf = std::numeric_limits<long double>::infinity(); if (exp & 1)
result = (result < 0) ? -inf : inf;
}
else if (exp < std::numeric_limits<long double>::min_exponent10)
{
result = 0.0L;
}
else if (exp < 0)
{
exp = -exp;
for (std::size_t count = 0; exp; ++count, exp >>= 1)
{ {
if (exp & 1) result /= powerof10[count];
{
result /= powerof10[count];
}
} }
} }
else }
else
{
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) result *= powerof10[count];
{
result *= powerof10[count];
}
} }
} }
} }

View File

@ -8197,41 +8197,38 @@ skip_loop:
} }
// adjust number by powers of ten specified by format and exponent. // adjust number by powers of ten specified by format and exponent.
if (result != 0.0L) constexpr std::array<long double, 9> powerof10 = {
{1.e1L, 1.e2L, 1.e4L, 1.e8L, 1.e16L, 1.e32L, 1.e64L, 1.e128L, 1.e256L}
};
if (exp > std::numeric_limits<long double>::max_exponent10)
{ {
constexpr std::array<long double, 9> powerof10 = { constexpr long double inf = std::numeric_limits<long double>::infinity();
{1.e1L, 1.e2L, 1.e4L, 1.e8L, 1.e16L, 1.e32L, 1.e64L, 1.e128L, 1.e256L} result = (result < 0) ? -inf : inf;
}; }
else if (exp < std::numeric_limits<long double>::min_exponent10)
{
result = 0.0L;
}
else if (exp < 0)
{
exp = -exp;
if (exp > std::numeric_limits<long double>::max_exponent10) for (std::size_t count = 0; exp; ++count, exp >>= 1)
{ {
constexpr long double inf = std::numeric_limits<long double>::infinity(); if (exp & 1)
result = (result < 0) ? -inf : inf;
}
else if (exp < std::numeric_limits<long double>::min_exponent10)
{
result = 0.0L;
}
else if (exp < 0)
{
exp = -exp;
for (std::size_t count = 0; exp; ++count, exp >>= 1)
{ {
if (exp & 1) result /= powerof10[count];
{
result /= powerof10[count];
}
} }
} }
else }
else
{
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) result *= powerof10[count];
{
result *= powerof10[count];
}
} }
} }
} }