Skip to content

Commit 088a48f

Browse files
authored
Merge pull request #821 from cppalliance/805
Fix `decimal128_fast` `scalblnd` implementation
2 parents 7e5c7be + 1b8a11b commit 088a48f

File tree

3 files changed

+33
-1
lines changed

3 files changed

+33
-1
lines changed

include/boost/decimal/decimal128_fast.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1370,7 +1370,7 @@ constexpr auto scalblnd128f(decimal128_fast num, long exp) noexcept -> decimal12
13701370
}
13711371
#endif
13721372

1373-
num.exponent_ = static_cast<decimal128_fast::exponent_type>(static_cast<long>(num.biased_exponent()) + exp);
1373+
num = decimal128_fast(num.significand_, num.biased_exponent() + exp, num.sign_);
13741374

13751375
return num;
13761376
}

test/Jamfile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ run github_issue_448.cpp ;
5151
run-fail github_issue_519.cpp ;
5252
run github_issue_799.cpp ;
5353
run github_issue_802.cpp ;
54+
run github_issue_805.cpp ;
5455
run link_1.cpp link_2.cpp link_3.cpp ;
5556
run quick.cpp ;
5657
run random_decimal32_comp.cpp ;

test/github_issue_805.cpp

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
// Copyright 2025 Matt Borland
2+
// Distributed under the Boost Software License, Version 1.0.
3+
// https://www.boost.org/LICENSE_1_0.txt
4+
5+
#include <boost/decimal.hpp>
6+
#include <boost/core/lightweight_test.hpp>
7+
#include <iostream>
8+
9+
using namespace boost::decimal;
10+
11+
template <typename Dec>
12+
void test()
13+
{
14+
Dec a(2, std::numeric_limits<Dec>::max_exponent10);
15+
Dec b = scalbln(a, 10);
16+
17+
BOOST_TEST(isinf(b));
18+
}
19+
20+
int main()
21+
{
22+
test<decimal32>();
23+
test<decimal64>();
24+
test<decimal128>();
25+
test<decimal32_fast>();
26+
test<decimal64_fast>();
27+
test<decimal128_fast>();
28+
29+
return boost::report_errors();
30+
}
31+

0 commit comments

Comments
 (0)