I have a simple problem but it seems to be quite involved: I want to print
floating point numbers with a given number of decimal points.
First, I found out that both ghc and hugs do not consider the precision
argument to showPrec. In fact, the standard prelude of Haskell 98 proposes
to drop the precision argument in showsPrec in the Show instances of Float
and Double.
Then I tried to round the numbers myself but I could not find an
appropriate function. RealFrac.round could be used for that but it returns
an integer. So a wrapper is needed which multiplies the number with 10^n,
where n is the number of decimal points, before rounding. I don't like
this because it might cause an overflow.
I ended up using Numeric.ShowFFloat. I don't like this solution because it
is unnecessarily complicated.
Michael