Haskell: Force floats to have two decimals

Anders picture Anders · Oct 13, 2009 · Viewed 13.8k times · Source

Using the following code snippet:

(fromIntegral 100)/10.00

Using the Haskell '98 standard prelude, how do I represent the result with two decimals?

Thanks.

Answer

viaclectic picture viaclectic · Feb 24, 2010

Just for the record:

import Numeric 
formatFloatN floatNum numOfDecimals = showFFloat (Just numOfDecimals) floatNum ""