<?xml version="1.0"?>
<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/">
	<channel>
		<title>Common problems - Revision history</title>
		<link>http://www.opengenie.org/index.php?title=Common_problems&amp;action=history</link>
		<description>Revision history for this page on the wiki</description>
		<language>en</language>
		<generator>MediaWiki 1.35.13</generator>
		<lastBuildDate>Wed, 10 Jun 2026 16:31:02 GMT</lastBuildDate>
		<item>
			<title>Freddie Akeroyd: New page: ==Why does A/B give the wrong answer?== If A and B are both integers, then integer division is performed; if either is a floating point number then the integer value is first converted int...</title>
			<link>http://www.opengenie.org/index.php?title=Common_problems&amp;diff=20&amp;oldid=prev</link>
			<guid isPermaLink="false">http://www.opengenie.org/index.php?title=Common_problems&amp;diff=20&amp;oldid=prev</guid>
			<description>&lt;p&gt;New page: ==Why does A/B give the wrong answer?== If A and B are both integers, then integer division is performed; if either is a floating point number then the integer value is first converted int...&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;==Why does A/B give the wrong answer?==&lt;br /&gt;
If A and B are both integers, then integer division is performed; if either is a floating point number then the integer value is first converted into a floating point number before division is performed. Thus:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
1/2 == 0       # 1 and 2 are of Integer type&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
but&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
1/2.0 == 0.5   # 2.0 is a floating point number, so integer 1 is converted to 1.0 before division is done&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
If you are unsure what data type two variables may be, then you can force real division using either of these statements&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
RES = AS_REAL(A) / B&lt;br /&gt;
RES = 1.0 * A / B   # equivalent to  (1.0*A)/B  as &amp;quot;*&amp;quot; and &amp;quot;/&amp;quot; are equal priority so the expression is evaluated left to right&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;/div&gt;</description>
			<pubDate>Wed, 27 May 2009 17:29:01 GMT</pubDate>
			<dc:creator>Freddie Akeroyd</dc:creator>
			<comments>http://www.opengenie.org/Talk:Common_problems</comments>
		</item>
</channel></rss>