<div dir="ltr">I think `mulAdd a b c` should be implemented as `a*b+c` even for Double/Float. It should only be an "optmization" (as in modular arithmetic), not a semantic changing operation. Thus justifying the optimization.<div><br></div><div>"fma" should be the "more-precise" version available for Float/Double. I don't think it makes sense to have "fma" for other types. That's why I'm advocating "mulAdd" to be part of "Num" for optimization purposes; and "fma" reserved for true IEEE754 types and semantics.</div><div><br></div><div>I understand that Edward doesn't like this as this requires a different class; but really, that's the price to pay if we claim Haskell has proper support for IEEE754 semantics. (Which I think it should.) The operation is just different. It also should account for the rounding-modes properly.</div><div><br></div><div>I think we can pull this off just fine; and Haskell can really lead the pack here. The situation with floats is even worse in other languages. This is our chance to make a proper implementation, and we have the right tools to do so.</div><div><br></div><div>-Levent.</div></div><div class="gmail_extra"><br><div class="gmail_quote">On Mon, May 4, 2015 at 10:58 AM, Artyom <span dir="ltr"><<a href="mailto:yom@artyom.me" target="_blank">yom@artyom.me</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div text="#000000" bgcolor="#FFFFFF"><span class="">
On 05/04/2015 08:49 PM, Levent Erkok wrote:<br>
<blockquote type="cite">
<div dir="ltr">Artyom: That's precisely the point. The true
IEEE754 variants where precision does matter should be part of a
different class. What Edward and Yitz want is an "optimized"
multiply-add where the semantics is the same but one that goes
faster.</div>
</blockquote></span>
No, it looks to me that Edward wants to have a more precise
operation in Num:<span class=""><br>
<blockquote type="cite">I'd have to make a second copy of the
function to even try to see the precision win.</blockquote></span>
Unless I'm wrong, you can't have the following things
simultaneously:<br>
<ol>
<li>the compiler is free to substitute <i>a+b*c</i> with <i>mulAdd
a b c</i></li>
<li><i>mulAdd a b c</i> is implemented as <i>fma</i> for Doubles
(and is more precise)</li>
<li>Num operations for Double (addition and multiplication) always
conform to IEEE754</li>
</ol>
<p><span class="">
</span></p><blockquote type="cite">The true IEEE754 variants where precision
does matter should be part of a different class.</blockquote>
So, does it mean that you're fine with not having point #3 because
people who need it would be able to use a separate class for
IEEE754 floats?<br>
<p></p>
</div>
</blockquote></div><br></div>