File tree Expand file tree Collapse file tree 2 files changed +37
-0
lines changed
Expand file tree Collapse file tree 2 files changed +37
-0
lines changed Original file line number Diff line number Diff line change @@ -88,3 +88,4 @@ run ../examples/charconv.cpp ;
8888# Github Issues
8989run github_issue_207.cpp ;
9090run github_issue_210.cpp ;
91+ run github_issue_221.cpp ;
Original file line number Diff line number Diff line change 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+ // See: https://github.com/cppalliance/int128/issues/221
6+
7+ #include < boost/int128.hpp>
8+ #include < boost/core/lightweight_test.hpp>
9+ #include < random>
10+ #include < limits>
11+
12+ constexpr std::size_t N {1024u };
13+ static std::mt19937_64 gen (42 );
14+
15+ template <typename T>
16+ void test ()
17+ {
18+ constexpr T numerator {0 };
19+
20+ using dist_type = std::conditional_t <std::numeric_limits<T>::is_signed, std::int64_t , std::uint64_t >;
21+ std::uniform_int_distribution<dist_type> dist {std::numeric_limits<dist_type>::min (), std::numeric_limits<dist_type>::max ()};
22+
23+ for (std::size_t i {0 }; i < N; ++i)
24+ {
25+ const auto value {dist (gen)};
26+ BOOST_TEST_EQ (numerator / value, numerator);
27+ }
28+ }
29+
30+ int main ()
31+ {
32+ test<boost::int128::int128_t >();
33+ test<boost::int128::uint128_t >();
34+
35+ return boost::report_errors ();
36+ }
You can’t perform that action at this time.
0 commit comments