<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
	<title type="html"><![CDATA[FrontAccounting forum — Strangest bug I've ever since]]></title>
	<link rel="self" href="https://frontaccounting.com/punbb/extern.php?action=feed&amp;tid=4886&amp;type=atom" />
	<updated>2014-04-12T15:54:54Z</updated>
	<generator>PunBB</generator>
	<id>https://frontaccounting.com/punbb/viewtopic.php?id=4886</id>
		<entry>
			<title type="html"><![CDATA[Re: Strangest bug I've ever since]]></title>
			<link rel="alternate" href="https://frontaccounting.com/punbb/viewtopic.php?pid=19714#p19714" />
			<content type="html"><![CDATA[<p>Yes, it&#039;s about precision. The way how computer store floating point. See here for <br /><a href="http://www.leaseweblabs.com/2013/06/the-php-floating-point-precision-is-wrong-by-default/">http://www.leaseweblabs.com/2013/06/the … y-default/</a></p><p>and here<br /><a href="http://www.php.net/manual/en/language.types.float.php">http://www.php.net/manual/en/language.types.float.php</a></p><p>lesson learned from php.net link:<br />&quot;So never trust floating number results to the last digit, and do not compare floating point numbers directly for equality.&quot;</p>]]></content>
			<author>
				<name><![CDATA[mfaa98]]></name>
				<uri>https://frontaccounting.com/punbb/profile.php?id=17843</uri>
			</author>
			<updated>2014-04-12T15:54:54Z</updated>
			<id>https://frontaccounting.com/punbb/viewtopic.php?pid=19714#p19714</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: Strangest bug I've ever since]]></title>
			<link rel="alternate" href="https://frontaccounting.com/punbb/viewtopic.php?pid=19713#p19713" />
			<content type="html"><![CDATA[<p>Yes, it&#039;s the rounding issue. But, I already print the $x which is exactly same as 0.84.</p>]]></content>
			<author>
				<name><![CDATA[barbarian]]></name>
				<uri>https://frontaccounting.com/punbb/profile.php?id=18954</uri>
			</author>
			<updated>2014-04-12T00:15:29Z</updated>
			<id>https://frontaccounting.com/punbb/viewtopic.php?pid=19713#p19713</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: Strangest bug I've ever since]]></title>
			<link rel="alternate" href="https://frontaccounting.com/punbb/viewtopic.php?pid=19710#p19710" />
			<content type="html"><![CDATA[<p>I&#039;m not a programmer so don&#039;t be insulted if this doesn&#039;t help you but you simply have a rounding issue. 1.1102230246252E-16 is technically 0.00000000000000001102230246252 which for anyone&#039;s purpose is 0.</p><p>I&#039;m not sure if you have something in the logger function that could be doing it but could you just add an operation to truncate some decimal places before the final result? Sorry if that doesn&#039;t help.</p>]]></content>
			<author>
				<name><![CDATA[hansenb88]]></name>
				<uri>https://frontaccounting.com/punbb/profile.php?id=18650</uri>
			</author>
			<updated>2014-04-11T13:53:51Z</updated>
			<id>https://frontaccounting.com/punbb/viewtopic.php?pid=19710#p19710</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Strangest bug I've ever since]]></title>
			<link rel="alternate" href="https://frontaccounting.com/punbb/viewtopic.php?pid=19708#p19708" />
			<content type="html"><![CDATA[<p>I don&#039;t know how to explain this. I&#039;m still confused with this bug. I have some strange bug and I&#039;m trying to debugging until I found the root problem. I&#039;ve just try some simple substraction but it gives me strange result. Here is my code:</p><div class="codebox"><pre><code>$x = 0.56*1.5;
logger($x-0.84);</code></pre></div><p>What I expection is 0, but the result is : 1.1102230246252E-16</p><p>If you want to know what is logger function, it&#039;s some function that I create to echo the parameter. The stranger thing is, this bug only happen to 2 decimal place operation. If I try with</p><div class="codebox"><pre><code>$x = 0.5*1.5;
logger($x-0.75);</code></pre></div><p>It works fine. I already check the variable type. Both show me they are double. Can anyone hlep me?</p>]]></content>
			<author>
				<name><![CDATA[barbarian]]></name>
				<uri>https://frontaccounting.com/punbb/profile.php?id=18954</uri>
			</author>
			<updated>2014-04-11T12:55:56Z</updated>
			<id>https://frontaccounting.com/punbb/viewtopic.php?pid=19708#p19708</id>
		</entry>
</feed>
