Boost C++ Libraries: Ticket #12908: Assert in next.hpp function float_distance with boost::multiprecision::cpp_dec_float_50 https://svn.boost.org/trac10/ticket/12908 <p> A very few inputs to float_distance cause a BOOST_ASSERT to fire at line 380 BOOST_ASSERT(result == floor(result)); </p> <p> A single example found is: </p> <p> result 7.5104779560206957400348257098619840395218651150916, floor(result) = 7.0000000000000000000000000000000000000000000000000 Float_distance parameter a = 1.3267246652422002236350992977580796601287935546380, b = 1.3267246652422002236350992977580796601287935546381 1&gt; Assertion failed: result == floor(result), file i:\modular-boost\boost\math\special_functions\next.hpp, line 387 </p> <p> The result to return from float_distance is expected to be an integral value, but for this example is not. </p> <p> This example was found using Boost.Test testing all floating-point types, including built-in and Boost.Multiprecision types. Only the decimal type failed, with the binary Boost.Multiprecision type working as expected. </p> <p> (The objective of using float_distance was to find the number of bits 'wrong' in estimation of the Lambert_w function. The float_distance function may be less informative with decimal types? After commenting out the assert or building release version works as expected passing the Boost.Test BOOST_CHECK_CLOSE_FRACTION. The complete diagnostic information is below). </p> <p> x = 5.0000000000000000000000000000000000000000000000000, 1st approximation = 1.3580516899453466985241032060217449722205837894767 Iteration <a class="missing ticket">#0</a>, w0 1.3580516899453466985241032060217449722205837894767, w1 = 1.3267307975239098478154332577910055570547859817317, difference = 0.023607571694190959083521171155401856568500751382772, relative 0.023607571694190959083521171155401856568500751382772 f'(x) = 0.030637621044026712522396263905986832827907006395521, f<em>(x) = -0.031320892421436850708669948230739415165797807744979 Iteration <a class="closed ticket" href="https://svn.boost.org/trac10/ticket/1" title="#1: Bugs: boost.build causes ftjam to segfault (closed: Wont Fix)">#1</a>, w0 1.3267307975239098478154332577910055570547859817317, w1 = 1.3267246652422002700196628232995006483530574240972, difference = 4.6221208290103786210868929801267062674723441825020e-06, relative 4.6221208290103786210868929801267062674723441825020e-06 f'(x) = 6.1322548262011945248563701546564283036693266139626e-06, f</em>(x) = -6.1322817095777957704344915049087017285576344382728e-06 1&gt; Iteration <a class="closed ticket" href="https://svn.boost.org/trac10/ticket/2" title="#2: Bugs: list::size should be const (closed: fixed)">#2</a>, w0 1.3267246652422002700196628232995006483530574240972, w1 = 1.3267246652422002236350992977580796601287935546381, difference = 3.4961710399100545033506658399263431373381321572551e-17, relative 3.4961710399100545033506658399263431373381321572551e-17 f'(x) = 4.6384563525541419450109229082502667458865618273589e-17, f<em>(x) = -4.6384563525541420988224263869459174491854618532511e-17 Refined 1.3267246652422002236350992977580796601287935546380 after 2 iterations, difference = 1.5130298669100961690698000000000000000000000000000e-50 result 7.5104779560206957400348257098619840395218651150916, floor(result) = 7.0000000000000000000000000000000000000000000000000 Float_distance parameter a 1.3267246652422002236350992977580796601287935546380, b = 1.3267246652422002236350992977580796601287935546381 Assertion failed: result == floor(result), file i:\modular-boost\boost\math\special_functions\next.hpp, line 387 unknown location : fatal error : in "test_main": abort() has been called i:\modular-boost\libs\math\test\test_lambert_w.cpp(183): last checkpoint </em></p> <p> <strong>* 1 failure is detected in the test module "Master Test Suite" </strong></p> en-us Boost C++ Libraries /htdocs/site/boost.png https://svn.boost.org/trac10/ticket/12908 Trac 1.4.3 John Maddock Sat, 30 Dec 2017 18:45:32 GMT status changed; resolution set https://svn.boost.org/trac10/ticket/12908#comment:1 https://svn.boost.org/trac10/ticket/12908#comment:1 <ul> <li><strong>status</strong> <span class="trac-field-old">new</span> → <span class="trac-field-new">closed</span> </li> <li><strong>resolution</strong> → <span class="trac-field-new">fixed</span> </li> </ul> <p> This was fixed in <a class="ext-link" href="https://github.com/boostorg/math/commit/9b2f8781034702a650ed375e4ba05588339fedd7#diff-6b50972ab602a4e7e699c7c18660d431"><span class="icon">​</span>https://github.com/boostorg/math/commit/9b2f8781034702a650ed375e4ba05588339fedd7#diff-6b50972ab602a4e7e699c7c18660d431</a> </p> Ticket