[Haskell-cafe] floating point operations and representation
Don Stewart
dons at galois.com
Thu Mar 13 00:57:48 EDT 2008
> I am under the restriction that I need to write Haskell programs using
> Double which mimic existing C/C++ programs or generated data sets, and
> get the same answers. (It's silly, but take it as a given
> requirement.) If the C programs are using "log2", then I need "log2"
> in the Haskell, or else I run the risk of not producing the same
> answers.
Hey Jacob,
Just to make life super simple, I packaged up a binding to the basic
math.h library for Doubles. You can find the library here:
http://hackage.haskell.org/cgi-bin/hackage-scripts/package/cmath
For example,
Prelude> Foreign.C.Math.Double.log10 5
0.6989700043360189
Prelude> log 5 / log 10
0.6989700043360187
Enjoy!
-- Don
More information about the Haskell-Cafe
mailing list