Boost C++ Libraries: Ticket #74: timeconv.inl to_duration() nsec error https://svn.boost.org/trac10/ticket/74 <pre class="wiki">The computation for number of milliseconds to Sleep() reads milliseconds = static_cast&lt;unsigned&gt;(((xt.sec - cur.sec) * MILLISECONDS_PER_SECOND) + (((xt.nsec - cur.nsec) + (NANOSECONDS_PER_MILLISECOND/2)) / NANOSECONDS_PER_MILLISECOND)); This computation is incorrect when xt.sec &gt; cur.sec, but xt.nsec &lt; cur.nsec. For example xt.sec = 1019600872 xt.nsec = 44320000 cur.sec = 1019600871 cur.nsec = 977320000 </pre> en-us Boost C++ Libraries /htdocs/site/boost.png https://svn.boost.org/trac10/ticket/74 Trac 1.4.3 Markus Schöpflin Wed, 23 Nov 2005 10:46:04 GMT <link>https://svn.boost.org/trac10/ticket/74#comment:1 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/74#comment:1</guid> <description> <pre class="wiki">Logged In: YES user_id=91733 to_duration() seems to have been fixed in the meantime. But to_microduration() still contains the same problem. And probably a merge or copy&amp;past error, because the following lines look suspect when compared with to_duration(). (Note the duplicate call to xtime_get().) ... res = boost::xtime_get(&amp;cur, boost::TIME_UTC); assert(res == boost::TIME_UTC); if (boost::xtime_get(&amp;cur, boost::TIME_UTC) &lt;= 0) microseconds = 0; else ... The two functions look nearly identical anyway, can't this be implemented in a generic manner? </pre> </description> <category>Ticket</category> </item> <item> <dc:creator>martin_wille</dc:creator> <pubDate>Fri, 06 Jan 2006 12:29:07 GMT</pubDate> <title>status changed https://svn.boost.org/trac10/ticket/74#comment:2 https://svn.boost.org/trac10/ticket/74#comment:2 <ul> <li><strong>status</strong> <span class="trac-field-old">assigned</span> → <span class="trac-field-new">closed</span> </li> </ul> <pre class="wiki">Logged In: YES user_id=592361 I copied the fix from to_duration to to_microduration(). The duplicate function call had been removed before. This should fix the problems reported in this thread. The potential for some code cleanup remains. </pre> Ticket