1 Star 0 Fork 36

zhangwenlong01/boost

forked from src-openEuler/boost 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
boost-1.81-random-Update-multiprecision_int_test.cpp-to-not-accidental.patch 1.62 KB
一键复制 编辑 原始数据 按行查看 历史
Liu Yuntao 提交于 2023-02-10 15:18 . Update to 1.81.1
From 7561690135c67ecf88c2133bad7680ebd2665c36 Mon Sep 17 00:00:00 2001
From: jzmaddock <[email protected]>
Date: Wed, 1 Jun 2022 19:32:55 +0100
Subject: [PATCH] Update multiprecision_int_test.cpp to not accidentality
overflow type double. Multiprecision now performs correct rounding when
converting to double - previously the max value for uint1024_t would just fit
in a double if it was truncated. But now that it's correctly rounded it
overflows and breaks the calculation.
---
libs/random/test/multiprecision_int_test.cpp | 7 +++++--
1 file changed, 5 insertions(+), 2 deletions(-)
diff --git a/libs/random/test/multiprecision_int_test.cpp b/libs/random/test/multiprecision_int_test.cpp
index 41ec229..a861cca 100644
--- a/libs/random/test/multiprecision_int_test.cpp
+++ b/libs/random/test/multiprecision_int_test.cpp
@@ -215,8 +215,11 @@ BOOST_AUTO_TEST_CASE_TEMPLATE(discrete_distributions, distribution_type, other_d
distribution_type d2;
ss >> d2;
BOOST_CHECK(d == d2);
-
- boost::random::independent_bits_engine<boost::random::mt19937, std::numeric_limits<boost::multiprecision::uint1024_t>::digits, boost::multiprecision::uint1024_t > big_random;
+ //
+ // The number of digits in the independent_bits_engine must be low enough that we don't overflow
+ // when converting to a double (see other_distributions declared above).
+ //
+ boost::random::independent_bits_engine<boost::random::mt19937, std::numeric_limits<boost::multiprecision::uint1024_t>::digits - 2, boost::multiprecision::uint1024_t > big_random;
for(unsigned i = 0; i < 200; ++i)
{
result_type r = d(big_random);
--
2.33.0
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/zhangwenlong01/boost.git
[email protected]:zhangwenlong01/boost.git
zhangwenlong01
boost
boost
master

搜索帮助