Skip to content
Go to file
This branch is 80 commits ahead, 111 commits behind ekmett:master.

Latest commit


Git stats


Failed to load latest commit information.
Latest commit message
Commit time



Build Status

This package provides properly rounded floating point numbers of arbitrary precision.

It does so by wrapping the GNU MPFR library. However, it actually contains a patched copy of MPFR 3.1.0, which has been updated to be compatible with GHC's use of GMP's garbage collection hook.

Phantom types carry the information about the precision and rounding mode, letting you treat properly rounded floating point numbers as instances of Num or Floating, like any other numeric type in Haskell.

Unlike other attempts to port MPFR to Haskell, this library does not require you to cripple Integer performance or link your code in an unnatural way.


{-# LANGUAGE DataKinds #-}
import Numeric.Rounded

To use a 53 bit significand (the same size as used by a Double), and round down intermediate results:

>>> pi :: Rounded TowardZero Double

We can also round away from zero, or use other rounding modes.

>>> pi :: Rounded AwayFromZero Double

We can specify the significand size directly using type literals in GHC:

>>> kCatalan :: Rounded TowardZero 128

You can also specify a dynamic significand size at runtime:

>>> reifyPrecision 512 (\(_ :: Proxy p) -> show (logBase 10 2 :: Rounded TowardNearest p))

or a dynamic rounding mode:

ghci> reifyRounding TowardZero (\(_ :: Proxy r) -> show (logBase 10 2 :: Rounded r 512))

Contact Information

Please, feel free to contact me with questions, concerns, or bug fixes.

I can be reached as ekmett via github or as edwardk on the #haskell IRC channel on

-Edward Kmett

You can’t perform that action at this time.