[Haskell-cafe] How to round off frational number?
sarakenedy at gmail.com
Sat Sep 9 15:56:26 EDT 2006
Thanks a lot. That's what I need.
On 9/8/06, J. Garrett Morris <trevion at gmail.com> wrote:
> I've always used:
> roundn n f = fromIntegral (round (f * 10 ^ n)) / 10 ^ n
> I may have missed some bugs or subtleties of floating point numbers, though.
> On 9/8/06, Sara Kenedy <sarakenedy at gmail.com> wrote:
> > Hello all,
> > I try to find some functions in Haskell library to deal with numeric
> > such that the result in the following format (but I did not find)
> > For example,
> > >1/3
> > 0.33
> > >1/6
> > 0.17
> > >8/3
> > 2.67
> > >9/3
> > 3.00
> > It seems a so "baby" question, but I really did not find the answer
> > after trying on that for some hours.
> > Thanks for any help.
> > _______________________________________________
> > Haskell-Cafe mailing list
> > Haskell-Cafe at haskell.org
> > http://www.haskell.org/mailman/listinfo/haskell-cafe
> It is myself I have never met, whose face is pasted on the underside of my mind.
More information about the Haskell-Cafe