Boost C++ Libraries: Ticket #6280: numeric_cast throws on exactly representable conversion https://svn.boost.org/trac10/ticket/6280 <p> If a double or float representing the smallest possible value of int64_t is cast to int64_t using numeric_cast, an exception is thrown saying that a negative overflow has occured. </p> <p> I would expect the cast to work, since the value is exactly representable in the target type. Since the absolute value is a power of two, there should not be any error in the floating point representation. </p> <p> This is also reproducable in trunk, according to <a class="missing wiki">VeXocide</a>. I found the problem in Boost 1.47.0 on Windows, using MinGW 4.5.2. </p> en-us Boost C++ Libraries /htdocs/site/boost.png https://svn.boost.org/trac10/ticket/6280 Trac 1.4.3 Simeon Maxein <smaxein@…> Fri, 16 Dec 2011 21:55:11 GMT attachment set https://svn.boost.org/trac10/ticket/6280 https://svn.boost.org/trac10/ticket/6280 <ul> <li><strong>attachment</strong> → <span class="trac-field-new">main.cpp</span> </li> </ul> <p> Small test program </p> Ticket wellnhofer@… Mon, 06 Jun 2016 19:21:07 GMT <link>https://svn.boost.org/trac10/ticket/6280#comment:1 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/6280#comment:1</guid> <description> <p> This works for me with Boost 1.58 on Ubuntu, but <code>ldrexp(1, 63)</code> doesn't throw. See ticket <a class="new ticket" href="https://svn.boost.org/trac10/ticket/12252" title="#12252: Bugs: numeric_cast&lt;int64_t&gt;(pow(2.0, 63.0)) doesn't throw (new)">#12252</a>. </p> </description> <category>Ticket</category> </item> </channel> </rss>