File tree Expand file tree Collapse file tree 3 files changed +33
-6
lines changed
include/boost/multiprecision Expand file tree Collapse file tree 3 files changed +33
-6
lines changed Original file line number Diff line number Diff line change @@ -432,12 +432,20 @@ class cpp_double_fp_backend
432
432
return *this ;
433
433
}
434
434
435
- const auto iszero_u = (fpc_u == FP_ZERO);
435
+ const auto iszero_u = (( fpc_u == FP_ZERO) || (fpc_u == FP_SUBNORMAL) );
436
436
const auto isnan_v = (fpc_v == FP_NAN);
437
437
438
438
if (iszero_u || (isnan_v || isinf_v))
439
439
{
440
- return operator =(v);
440
+ if (iszero_u)
441
+ {
442
+ data.first = float_type { 0 .0F };
443
+ data.second = float_type { 0 .0F };
444
+ }
445
+
446
+ const auto iszero_v = ((fpc_v == FP_ZERO) || (fpc_v == FP_SUBNORMAL));
447
+
448
+ return ((!iszero_v) ? operator =(v) : *this );
441
449
}
442
450
443
451
if (this == &v)
@@ -482,12 +490,20 @@ class cpp_double_fp_backend
482
490
return *this ;
483
491
}
484
492
485
- const auto iszero_u = (fpc_u == FP_ZERO);
493
+ const auto iszero_u = (( fpc_u == FP_ZERO) || (fpc_u == FP_SUBNORMAL) );
486
494
const auto isnan_v = (fpc_v == FP_NAN);
487
495
488
496
if (iszero_u || (isnan_v || isinf_v))
489
497
{
490
- return operator =(-v);
498
+ if (iszero_u)
499
+ {
500
+ data.first = float_type { 0 .0F };
501
+ data.second = float_type { 0 .0F };
502
+ }
503
+
504
+ const auto iszero_v = ((fpc_v == FP_ZERO) || (fpc_v == FP_SUBNORMAL));
505
+
506
+ return ((!iszero_v) ? operator =(-v) : *this );
491
507
}
492
508
493
509
if (this == &v)
Original file line number Diff line number Diff line change @@ -262,7 +262,7 @@ alias precision_tests : test_preserve_source_precision_gmp test_preserve_source_
262
262
rule get_function_tests
263
263
{
264
264
local result ;
265
- for local source in test_log .cpp test_pow .cpp test_pow_df .cpp test_sinh.cpp test_sqrt.cpp test_cosh.cpp test_tanh.cpp test_sin.cpp test_cos.cpp test_tan.cpp test_asin.cpp test_acos.cpp test_atan.cpp test_round.cpp test_fpclassify.cpp test_sf_import_c99.cpp
265
+ for local source in test_exp .cpp test_log .cpp test_pow .cpp test_sinh.cpp test_sqrt.cpp test_cosh.cpp test_tanh.cpp test_sin.cpp test_cos.cpp test_tan.cpp test_asin.cpp test_acos.cpp test_atan.cpp test_round.cpp test_fpclassify.cpp test_sf_import_c99.cpp
266
266
{
267
267
result += [ run $(source) gmp no_eh_support
268
268
: # command line
Original file line number Diff line number Diff line change 59
59
#include < boost/multiprecision/cpp_bin_float.hpp>
60
60
#endif
61
61
#ifdef TEST_CPP_DOUBLE_FLOAT
62
+ #if defined(BOOST_MATH_USE_FLOAT128)
63
+ #include < boost/multiprecision/float128.hpp>
64
+ #endif
62
65
#include < boost/multiprecision/cpp_double_fp.hpp>
63
66
#endif
64
67
@@ -206,8 +209,16 @@ void test()
206
209
BOOST_CHECK_LE (exp (bug_case), (std::numeric_limits<T>::min)());
207
210
}
208
211
}
212
+
209
213
bug_case = log ((std::numeric_limits<T>::max)()) / -1.0005 ;
210
- for (unsigned i = 0 ; i < 20 ; ++i, bug_case /= 1.05 )
214
+ unsigned i { 0U };
215
+
216
+ #if defined(TEST_CPP_DOUBLE_FLOAT)
217
+ BOOST_IF_CONSTEXPR (std::is_same<T, boost::multiprecision::cpp_double_float>::value) { for ( ; i < 7 ; ++i, bug_case /= 1.05 ) { ; } }
218
+ BOOST_IF_CONSTEXPR (std::is_same<T, boost::multiprecision::cpp_double_double>::value) { for ( ; i < 3 ; ++i, bug_case /= 1.05 ) { ; } }
219
+ BOOST_IF_CONSTEXPR (std::is_same<T, boost::multiprecision::cpp_double_long_double>::value) { for ( ; i < 3 ; ++i, bug_case /= 1.05 ) { ; } }
220
+ #endif
221
+ for ( ; i < 20U ; ++i, bug_case /= static_cast <T>(1 .05L ))
211
222
{
212
223
BOOST_CHECK_GE (exp (bug_case), (std::numeric_limits<T>::min)());
213
224
}
You can’t perform that action at this time.
0 commit comments