[Haskell-cafe] round function
achatzianastassiou at hotmail.com
Sun Feb 12 18:48:32 EST 2006
Ok, i have got it working.
Thanks for the posts
>From: "J. Garrett Morris" <trevion at gmail.com>
>To: sylvan at student.chalmers.se
>CC: Chatzianastassiou Achilleas <achatzianastassiou at hotmail.com>,
>haskell-cafe at haskell.org
>Subject: Re: [Haskell-cafe] round function
>Date: Sun, 12 Feb 2006 18:46:47 -0500
>Ah, okay. I misinterpreted.. I was thinking of round, just moving the
>other direction from the decimal point.
>On 2/12/06, Sebastian Sylvan <sebastian.sylvan at gmail.com> wrote:
> > On 2/13/06, J. Garrett Morris <trevion at gmail.com> wrote:
> > > I think the function you're looking for is:
> > >
> > > myRound n places = round (n / fromIntegral factor) * factor
> > > where factor = 10 ^ (places - 1)
> > >
> > This gives:
> > *Main> myRound 123123.123 2
> > 123120
> > Whereas my (revised) version gives
> > *Main> myround 123123.123 2
> > 120000.0
> > I may be wrong, but I think it's this latter result he's looking for(?).
> > /S
> > --
> > Sebastian Sylvan
> > +46(0)736-818655
> > UIN: 44640862
>We have lingered in the chambers of the sea
>By sea-girls wreathed with seaweed red and brown
>Till human voices wake us, and we drown.
Express yourself instantly with MSN Messenger! Download today - it's FREE!
More information about the Haskell-Cafe