Boost C++ Libraries: Ticket #11272: Incorrect use of abs() function in libs/math/example/normal_misc_examples.cpp https://svn.boost.org/trac10/ticket/11272 <p> When running normal_misc_examples, it produces the following error: </p> <pre class="wiki">If we want the 0.0500 th quantile to be located at 2.90, would need a standard deviation of 0.00 Message from thrown exception was: Error in function boost::math::normal_distribution&lt;double&gt;::normal_distribution: Scale parameter is 0, but must be &gt; 0 ! </pre><p> The reason for this is line 373: </p> <pre class="wiki">double sd95 = abs((x - mean)) / qp; </pre><p> where the abs() function is the C function which takes an int parameter. Passing it the double (x - mean) returns 0. </p> <p> As a temporary workaround, I have modified the code to </p> <pre class="wiki">double sd95 = (x - mean) / qp; if (sd95 &lt; 0) sd95 = -sd95 ; </pre><p> and this resolves the problem. </p> en-us Boost C++ Libraries /htdocs/site/boost.png https://svn.boost.org/trac10/ticket/11272 Trac 1.4.3 John Maddock Wed, 06 May 2015 17:47:20 GMT status changed; resolution set https://svn.boost.org/trac10/ticket/11272#comment:1 https://svn.boost.org/trac10/ticket/11272#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> abs is overloaded for floating point types in C++, but of course the call should be to std::abs. Fixed in <a class="ext-link" href="https://github.com/boostorg/math/commit/282a74beea5686b1d3f949e9328b455d9374aa34"><span class="icon">​</span>https://github.com/boostorg/math/commit/282a74beea5686b1d3f949e9328b455d9374aa34</a> </p> Ticket