<?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 the math 1&#x2F;2 dont return 0.5 ;]]></title><description><![CDATA[<p dir="auto">Hi, i have a strange problem, i have the code float test = 1/2;<br />
but returns test= 0 ;</p>
<p dir="auto">i cannot understand this, and my code don't work !<br />
See the screen shot from debugger!</p>
<p dir="auto">The problem is that the code on line 299 if(((dt%temp.period)==0), also dont work and i discover this inconvenience!</p>
<p dir="auto">!<a href="http://i57.tinypic.com/11r4oba.png" target="_blank" rel="noopener noreferrer nofollow ugc">http://i57.tinypic.com/11r4oba.png</a>!</p>
]]></description><link>https://forum.qt.io/topic/50522/why-the-math-1-2-dont-return-0-5</link><generator>RSS for Node</generator><lastBuildDate>Sat, 07 Nov 2026 13:17:05 GMT</lastBuildDate><atom:link href="https://forum.qt.io/topic/50522.rss" rel="self" type="application/rss+xml"/><pubDate>Sat, 24 Jan 2015 18:45:06 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Why the math 1&#x2F;2 dont return 0.5 ; on Sat, 24 Jan 2015 20:15:25 GMT]]></title><description><![CDATA[<p dir="auto">Not that any reasonable compiler wouldn't see this but why not just do this?<br />
@<br />
float test = 0.5f;<br />
@<br />
<a class="plugin-mentions-user plugin-mentions-a" href="/user/andreyc">@<bdi>andreyc</bdi></a> - again, not that any compiler wouldn't see this but if you define a float avoid downcasting from a double:<br />
@<br />
float test = 1.0f/2.0f;<br />
@</p>
]]></description><link>https://forum.qt.io/post/259054</link><guid isPermaLink="true">https://forum.qt.io/post/259054</guid><dc:creator><![CDATA[Chris Kawa]]></dc:creator><pubDate>Sat, 24 Jan 2015 20:15:25 GMT</pubDate></item><item><title><![CDATA[Reply to Why the math 1&#x2F;2 dont return 0.5 ; on Sat, 24 Jan 2015 19:55:34 GMT]]></title><description><![CDATA[<p dir="auto">Yes, you need to cast one of them if both of then integers:<br />
@<br />
int a = 1;<br />
int b = 2;<br />
float test = float(a) / b;<br />
@</p>
]]></description><link>https://forum.qt.io/post/259050</link><guid isPermaLink="true">https://forum.qt.io/post/259050</guid><dc:creator><![CDATA[ckakman]]></dc:creator><pubDate>Sat, 24 Jan 2015 19:55:34 GMT</pubDate></item><item><title><![CDATA[Reply to Why the math 1&#x2F;2 dont return 0.5 ; on Sat, 24 Jan 2015 19:20:10 GMT]]></title><description><![CDATA[<p dir="auto">good that means in if state need to make a casting ?</p>
]]></description><link>https://forum.qt.io/post/259051</link><guid isPermaLink="true">https://forum.qt.io/post/259051</guid><dc:creator><![CDATA[xmaze]]></dc:creator><pubDate>Sat, 24 Jan 2015 19:20:10 GMT</pubDate></item><item><title><![CDATA[Reply to Why the math 1&#x2F;2 dont return 0.5 ; on Sat, 24 Jan 2015 19:00:56 GMT]]></title><description><![CDATA[<p dir="auto">Try<br />
@float test = 1.0/2.0; @</p>
]]></description><link>https://forum.qt.io/post/259049</link><guid isPermaLink="true">https://forum.qt.io/post/259049</guid><dc:creator><![CDATA[andreyc]]></dc:creator><pubDate>Sat, 24 Jan 2015 19:00:56 GMT</pubDate></item></channel></rss>