Fix prelude definitions of abs/signum for Floats/Doubles
Daniel Fischer
daniel.is.fischer at googlemail.com
Mon Apr 22 01:10:07 CEST 2013
On Thursday 11 April 2013, 08:07:57, Levent Erkok wrote:
> On Thu, Apr 11, 2013 at 2:58 AM, Shachaf Ben-Kiki <shachaf at gmail.com> wrote:
> > Maybe it would be simpler to say:
> >
> > signum x | x == 0 = x
> >
> > | isNaN x = x
> > | x > 0 = 1
> > | otherwise = negate 1
> >
> > Shachaf
>
> Thanks Shachaf. This version is equivalent to the one I proposed, and it
> saves one test; so it's definitely preferable. I'll put this one in the
> ticket that'll finally be created for GHC.
Also
abs x
| x < 0 = negate x
| otherwise = x
keeps the number of tests at one.
Cheers,
Daniel
More information about the Libraries
mailing list