<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[Why would anyone write int(qRound(x)) ?]]></title><description><![CDATA[<p dir="auto">In the legacy codebase I'm working on (dating from Qt 4.8.7 or earlier) I often encounter statements similar to the following:</p>
<pre><code>int y = int(qRound(x));
</code></pre>
<p dir="auto">Looking at the Qt 5 documentation for <code>qRound</code> at <a href="https://doc.qt.io/qt-5/qtglobal.html" target="_blank" rel="noopener noreferrer nofollow ugc">https://doc.qt.io/qt-5/qtglobal.html</a> I see that <code>qRound</code>'s return type is <code>int</code>.  So why on earth would anyone use <code>int(qRound(x))</code> instead of just <code>qRound(x)</code>?  Would there be a good reason for this?  Maybe historically?  Has <code>qRound</code> always had a return type of <code>int</code>?  I'm planning to refactor this and remove the <code>int(.)</code>, but first would like to get a second opinion on whether there are pitfalls that I'm not thinking of...</p>
]]></description><link>https://forum.qt.io/topic/128071/why-would-anyone-write-int-qround-x</link><generator>RSS for Node</generator><lastBuildDate>Tue, 04 Aug 2026 18:27:17 GMT</lastBuildDate><atom:link href="https://forum.qt.io/topic/128071.rss" rel="self" type="application/rss+xml"/><pubDate>Wed, 30 Jun 2021 18:32:24 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Why would anyone write int(qRound(x)) ? on Thu, 01 Jul 2021 07:37:04 GMT]]></title><description><![CDATA[<p dir="auto">Thanks for confirming.  I'll remove the int(.) and go on with my life ;-)</p>
]]></description><link>https://forum.qt.io/post/668229</link><guid isPermaLink="true">https://forum.qt.io/post/668229</guid><dc:creator><![CDATA[Bart_Vandewoestyne]]></dc:creator><pubDate>Thu, 01 Jul 2021 07:37:04 GMT</pubDate></item><item><title><![CDATA[Reply to Why would anyone write int(qRound(x)) ? on Wed, 30 Jun 2021 18:47:45 GMT]]></title><description><![CDATA[<p dir="auto">it has always been an int since before the release of Qt 4.8.7<br />
I think that cast is there as a refuse from the STL (<code>std::round(double)</code> returns a double) and your compiler optimises it away in any case</p>
]]></description><link>https://forum.qt.io/post/668146</link><guid isPermaLink="true">https://forum.qt.io/post/668146</guid><dc:creator><![CDATA[VRonin]]></dc:creator><pubDate>Wed, 30 Jun 2021 18:47:45 GMT</pubDate></item></channel></rss>