[Haskell-cafe] Default implementation of Floating (**)

Viktor Dukhovni ietf-dane at dukhovni.org
Wed May 19 19:39:13 UTC 2021


On Wed, May 19, 2021 at 02:08:06PM -0300, Fabrício Olivetti de França wrote:

> > I guess he expects (-2)**(-2) = 1/4.
> >
> > But defined this way, (**) would be rather discontinuous
> 
> Indeed, that's what I was expecting. For Float and Double (-2)**(-2) =
> 1/4, but for the interval arithmetic library that uses the default
> implementation, it doesn't.

This shows the difference between the math library's

    pow(x, y) and exp(log(x)*y)

Indeed pow(x, y) appears to attempt to detect integer-valued floating
point exponents and take the interger-exponent code path in that case.

-- 
    Viktor.


More information about the Haskell-Cafe mailing list