Pure Haskell implementation of Float type?

Hello, Is there a pure Haskell implementation of Floats, i.e., one that (unlike GHC.Float) doesn't use foreign calls for things like isFloatNegativeZero? I don't care about performance; I'm just looking for something that doesn't use foreign calls. Thanks, Tim -- Tim Chevalier * http://cs.pdx.edu/~tjc * Often in error, never in doubt "It is easy to keep secrets by being honest in an ironic tone of voice." -- Andrew Solomon

catamorphism:
Hello, Is there a pure Haskell implementation of Floats, i.e., one that (unlike GHC.Float) doesn't use foreign calls for things like isFloatNegativeZero? I don't care about performance; I'm just looking for something that doesn't use foreign calls.
Huh, what's the use case? -- Don

On 1/20/09, Don Stewart
catamorphism:
Hello, Is there a pure Haskell implementation of Floats, i.e., one that (unlike GHC.Float) doesn't use foreign calls for things like isFloatNegativeZero? I don't care about performance; I'm just looking for something that doesn't use foreign calls.
Huh, what's the use case?
I'm implementing a compiler that doesn't support foreign calls (yet). Cheers, Tim -- Tim Chevalier * http://cs.pdx.edu/~tjc * Often in error, never in doubt "I cannot remember a time when I did not take it as understood that everybody has at least two, if not twenty-two, sides to him." -- Robertson Davies

Do you have Integer?
On Wed, Jan 21, 2009 at 12:23 AM, Tim Chevalier
On 1/20/09, Don Stewart
wrote: catamorphism:
Hello, Is there a pure Haskell implementation of Floats, i.e., one that (unlike GHC.Float) doesn't use foreign calls for things like isFloatNegativeZero? I don't care about performance; I'm just looking for something that doesn't use foreign calls.
Huh, what's the use case?
I'm implementing a compiler that doesn't support foreign calls (yet).
Cheers, Tim
-- Tim Chevalier * http://cs.pdx.edu/~tjc * Often in error, never in doubt "I cannot remember a time when I did not take it as understood that everybody has at least two, if not twenty-two, sides to him." -- Robertson Davies _______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe

On 1/20/09, Lennart Augustsson
Do you have Integer?
Yes (with the integer-simple library -- I was hoping there was some analogue of integer-simple for Float, although Don didn't think there was one). -t -- Tim Chevalier * http://cs.pdx.edu/~tjc * Often in error, never in doubt "Having the gumption to live different *and* the sense to let everybody else live different. That's the hardest thing, hands down." -- Alice Venable Middleton

There's the numbers package which contains BigFloat. You can pick
your own precision, but it's not IEEE.
It's actually base 10 floats which makes it more fun (actually, the
iEEE standard will cover base 10 floats in the future).
-- Lennart
On Wed, Jan 21, 2009 at 12:44 AM, Tim Chevalier
On 1/20/09, Lennart Augustsson
wrote: Do you have Integer?
Yes (with the integer-simple library -- I was hoping there was some analogue of integer-simple for Float, although Don didn't think there was one).
-t
-- Tim Chevalier * http://cs.pdx.edu/~tjc * Often in error, never in doubt "Having the gumption to live different *and* the sense to let everybody else live different. That's the hardest thing, hands down." -- Alice Venable Middleton

Lennart Augustsson schrieb:
There's the numbers package which contains BigFloat. You can pick your own precision, but it's not IEEE. It's actually base 10 floats which makes it more fun (actually, the iEEE standard will cover base 10 floats in the future).
Actually, all of the arbitrary precision real number implementations may be of interest for you: http://haskell.org/haskellwiki/Applications_and_libraries/Mathematics#Number... The NumericPrelude implementation by me, however, sometimes uses the Double implementation for speedup.

"Tim Chevalier"
Is there a pure Haskell implementation of Floats, i.e., one that (unlike GHC.Float) doesn't use foreign calls for things like isFloatNegativeZero? I don't care about performance; I'm just looking for something that doesn't use foreign calls.
You can easily do it yourself: data MyFloat m e = MyFloat m e | MyInfinity Bool | MyNaN A number x is represented in floating point as x = m * b^e, where m is called the mantissa, e the exponent and b the base. For performance reasons, usually b = 2 is chosen and both m and e are integers with fixed size. You'll find it useful to have a 'normalize' function, which 'moves the point', such that the mantissa isn't divisible by b, if possible. Greets, Ertugrul. -- nightmare = unsafePerformIO (getWrongWife >>= sex) http://blog.ertes.de/
participants (5)
-
Don Stewart
-
Ertugrul Soeylemez
-
Henning Thielemann
-
Lennart Augustsson
-
Tim Chevalier