Boost C++ Libraries: Ticket #448: interval evaluation bug https://svn.boost.org/trac10/ticket/448 <pre class="wiki">evaluation of sin of [0,1] with interval template specification typedef boost::numeric::interval&lt; double, boost::numeric::interval_lib::policies&lt; boost::numeric::interval_lib:: save_state&lt; boost::numeric::interval_lib:: rounded_transc_exact&lt;double, boost::numeric:: interval_lib::rounded_arith_opp&lt;double&gt; &gt; &gt;, boost::numeric::interval_lib:: checking_strict&lt;double&gt; //boost::numeric::interval_lib:: checking_base&lt;double&gt; &gt; &gt; Interval; and rint definition in ms Windows static double inline rint( double x) // Copyright (C) 2001 Tor M. Aamodt, University of Toronto // Permisssion to use for all purposes commercial and otherwise granted. // THIS MATERIAL IS PROVIDED "AS IS" WITHOUT WARRANTY, OR ANY CONDITION OR // OTHER TERM OF ANY KIND INCLUDING, WITHOUT LIMITATION, ANY WARRANTY // OF MERCHANTABILITY, SATISFACTORY QUALITY, OR FITNESS FOR A PARTICULAR // PURPOSE. { if( x &gt; 0 ) { __int64 xint = (__int64) (x+0.5); if( xint % 2 ) { // then we might have an even number... double diff = x - (double)xint; if( diff == -0.5 ) return double(xint-1); } return double(xint); } else { __int64 xint = (__int64) (x-0.5); if( xint % 2 ) { // then we might have an even number... double diff = x - (double)xint; if( diff == 0.5 ) return double(xint+1); } return double(xint); } } gives incorrect result: so sin([0,1]) = [ 0.841471 , -1.60814e-016 ] Thats looks incredible!!! How can i fix it out? </pre> en-us Boost C++ Libraries /htdocs/site/boost.png https://svn.boost.org/trac10/ticket/448 Trac 1.4.3 Guillaume Melquiond Thu, 28 Jul 2005 08:39:17 GMT <link>https://svn.boost.org/trac10/ticket/448#comment:1 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/448#comment:1</guid> <description> <pre class="wiki">Logged In: YES user_id=576737 Your rint function does not comply to the C standard; its behavior confuses the interval library. The interval library expects this function to "round its argument to an integer value in floating-point format, using the current rounding direction" (7.12.9 Nearest integer functions). You can workaround your deficient standard library by using the following code (supposing your standard library provides the floor and ceil functions at least): struct my_arith_rounding: boost::numeric::interval_lib::rounded_arith_opp&lt;double&gt; { double int_down(double f) { return floor(f); } double int_up (double f) { return ceil(f); } }; typedef boost::numeric::interval&lt; double, boost::numeric::interval_lib::policies&lt; boost::numeric::interval_lib::save_state&lt; boost::numeric::interval_lib::rounded_transc_exact&lt; double, my_arith_rounding &gt; &gt;, boost::numeric::interval_lib::checking_strict&lt;double&gt; &gt; &gt; Interval; </pre> </description> <category>Ticket</category> </item> <item> <dc:creator>Guillaume Melquiond</dc:creator> <pubDate>Thu, 28 Jul 2005 08:39:18 GMT</pubDate> <title>status changed https://svn.boost.org/trac10/ticket/448#comment:2 https://svn.boost.org/trac10/ticket/448#comment:2 <ul> <li><strong>status</strong> <span class="trac-field-old">assigned</span> → <span class="trac-field-new">closed</span> </li> </ul> Ticket