Skip to content

Commit 3a65fdc

Browse files
committed
Use explicit instead of automatic types
1 parent d98fcfb commit 3a65fdc

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

examples/rounding_mode.cpp

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -60,17 +60,18 @@ int main()
6060
#ifndef BOOST_DECIMAL_NO_CONSTEVAL_DETECTION
6161

6262
using namespace boost::decimal::literals;
63+
using boost::decimal::decimal32_t;
6364

64-
const auto lhs {"5e+50"_DF};
65-
const auto rhs {"4e+40"_DF};
65+
const decimal32_t lhs {"5e+50"_DF};
66+
const decimal32_t rhs {"4e+40"_DF};
6667

6768
std::cout << "lhs equals: " << lhs << '\n'
6869
<< "rhs equals: " << rhs << '\n';
6970

7071
// With upward rounding the result will be "5.000001e+50"_DF
7172
// Even though the difference in order of magnitude is greater than the precision of the type,
7273
// any addition in this mode will result in at least a one ULP difference
73-
const auto upward_res {lhs + rhs};
74+
const decimal32_t upward_res {lhs + rhs};
7475
std::cout << " Sum with upward rounding: " << upward_res << '\n';
7576

7677

@@ -79,7 +80,7 @@ int main()
7980
print_rounding_mode(new_rounding_mode);
8081

8182
// Similar to above in the downward rounding mode any subtraction will result in at least a one ULP difference
82-
const auto downward_res {lhs - rhs};
83+
const decimal32_t downward_res {lhs - rhs};
8384
std::cout << "Sum with downward rounding: " << downward_res << '\n';
8485

8586
#endif // BOOST_DECIMAL_NO_CONSTEVAL_DETECTION

0 commit comments

Comments
 (0)