dh-core icon indicating copy to clipboard operation
dh-core copied to clipboard

Implement DoubleDouble

Open Shimuuar opened this issue 7 years ago • 5 comments

It's way for emulating not quite quad-precision number using two doubles. Algorithms is interesting by itself and could have few uses. But I think its main value is providing example of constant size approximation of real numbers which isn't IEEE754. It would be very useful for implementing type classes for working with low level representations of numbers. Without such examples it's all to easy to assume that only single and double IEEE754 numbers exist

Julia implementation and references could be found here https://github.com/JuliaMath/DoubleDouble.jl

Shimuuar avatar Oct 31 '18 20:10 Shimuuar

@Shimuuar I am finding some packages that provide long double and arbitrary-precision operations:

  • https://hackage.haskell.org/package/long-double (FFI)
  • https://hackage.haskell.org/package/numbers-3000.2.0.2/docs/Data-Number-BigFloat.html numbers has a BigFloat module (native)
  • https://hackage.haskell.org/package/haskell-mpfr (FFI, maybe bitrotted)
  • https://hackage.haskell.org/package/hmpfr (FFI, recently updated)

ocramz avatar Apr 07 '19 10:04 ocramz

there's a long-standing GHC ticket to add CLDouble support : https://gitlab.haskell.org/ghc/ghc/issues/3353

ocramz avatar Apr 07 '19 10:04 ocramz

DoubleDouble (and triple double) is different approach. It's software emulation of something similar to quad precision.

  • Long double (80-bit) has 63-bit mantissa DoubleDouble has 2x (3x) of Double — 106 bit (162 bit). On other hand it doesn't have hardware support
  • Unlike arbitrary precision it has fixed size 128 (192) bit and thus could be easily unboxed/

Kahan's compensated summation is special case of this approach. I'm only aware of Julia's implementation of this algorithm

Shimuuar avatar Apr 07 '19 12:04 Shimuuar

@Shimuuar is this something you know how to implement? In case, would you like to do it?

ocramz avatar Apr 15 '19 07:04 ocramz

I have stack of papers on the subject, there's open source Julia implementation and no time to do anything :(

Shimuuar avatar Apr 15 '19 07:04 Shimuuar