[Haskell-cafe] ANN: variable-precision floating point

Claude Heiland-Allen claude at goto10.org
Wed May 16 21:18:00 CEST 2012

Hi all,

I'm pleased to announce variable-precision-0.2:


There was no announcement for previous versions, as I quickly found 
their flaws to be too irritating in practice.

--8<-- excerpt from the hackage page
Software floating point with type-tagged variable mantissa precision, 
implemented using a strict pair of Integer and Int scaled alike to 

Instances of the usual numeric type classes are provided, along with 
additional operators (with carefully chosen fixities) to coerce, adjust 
and reify precisions.
--8<-- end excerpt

Known shortcomings of this release:
   * no implementation of (inverse) (hyperbolic) trigonometric functions
   * no support for negative zero
   * no support for rounding modes
   * accuracy has not been extensively verified
   * termination of algorithms has not been proven

The intention of this package is to be simple yet useable in the 
meantime until there is a version of hmpfr[1] or fixed-precision[2] that 
work without requiring a custom-compiled GHC.  The design of 
variable-precision was inspired by the latter, and variable-precision is 
probably inferior, but the lifetime of the variable-precision package is 
hopefully going to be short.

[1] http://hackage.haskell.org/package/hmpfr
[2] http://hackage.haskell.org/package/fixed-precision

I'm currently mainly using variable-precision for exploring the 
Mandelbrot Set, particularly in algorithms using Newton's method (for 
example, tracing external rays, where more precision is needed the 
closer you get to the boundary of the set).



--8<-- excerpt from ghci session
Prelude Numeric.VariablePrecision> (pi :: F24) .@$ 200 $ show . (pi -)
Prelude Numeric.VariablePrecision> (pi :: F53) .@$ 200 $ show . (pi -)
Prelude Numeric.VariablePrecision> (2  :: F53) .@$ 200 $ show . log
Prelude Numeric.VariablePrecision> log 2
Prelude Numeric.VariablePrecision> (2  :: F53) .@$ 200 $ show . exp
Prelude Numeric.VariablePrecision> exp 2
--8<-- end excerpt

More information about the Haskell-Cafe mailing list