<br><br><div class="gmail_quote">On Thu, Nov 19, 2009 at 9:29 AM, John M McIntosh <span dir="ltr">&lt;<a href="mailto:johnmci@smalltalkconsulting.com">johnmci@smalltalkconsulting.com</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
<div class="im"><br>
&gt; define FLT_EPSILON as something like 1e-20 and rewrite the check as CHECK(fabs(f - ff) &lt; FLT_EPSILON)?<br>
&gt;<br>
&gt; In math epsilon is a small value tending towards zero.  The intent here is to check that you get back something close to ff without assuming that the floating-point arithmetic involved in many is exact enough to return ff.<br>

<br>
</div>Ok, the implication then for testing is that<br>
<br>
<br>
ffiPushSingleFloat<br>
ffiReturnFloatValue<br>
<br>
modify the floating point value slightly, if that is acceptable<br>
then you need to epsilon test.<br></blockquote><div><br></div><div>No.  Look at the body of many:</div><div><br></div><div>static float many(float f1, float f2, float f3, float f4, float f5, float f6, float f7, float f8, float f9, float f10, float f11, float f12, float f13, float f14, float f15)</div>
<div>{</div><div>  DPRINTF((&quot;%f %f %f %f %f %f %f %f %f %f %f %f %f %f %f\n&quot;,</div><div>     (double)f1, (double)f2, (double)f3, (double)f4, (double)f5,</div><div>     (double)f6, (double)f7, (double)f8, (double)f9, (double)f10,</div>
<div>     (double)f11, (double)f12, (double)f13, (double)f14, (double)f15));</div><div>  return ((f1/f2+f3/f4+f5/f6+f7/f8+f9/f10+f11/f12+f13/f14) * f15);</div><div>}</div><div><br></div><div>There&#39;s lots of scope for floating-point rounding errors here, so the epsilon test is required.  There&#39;s no implication that any float marshalling code alters the values involved.  That would be a huge bug.</div>
<div><br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
<br>
also GCC seems to define<br>
#define FLT_EPSILON 1.19209290e-07F<br>
across all flavours of CPUs and float word lengths.<br>
perhaps via &quot;float.h&quot;<br>
<font color="#888888"><br>
<br>
--<br>
===========================================================================<br>
John M. McIntosh &lt;<a href="mailto:johnmci@smalltalkconsulting.com">johnmci@smalltalkconsulting.com</a>&gt;   Twitter:  squeaker68882<br>
Corporate Smalltalk Consulting Ltd.  <a href="http://www.smalltalkconsulting.com" target="_blank">http://www.smalltalkconsulting.com</a><br>
===========================================================================<br>
<br>
<br>
<br>
<br>
</font></blockquote></div><br>