Re: [Haskell-cafe] Re: Double - CDouble, realToFrac doesn't work

2004-11-08 Thread Ben Rudiak-Gould
MR K P SCHUPKE wrote: Why is there no Irrational class. This would make more sense for Floats and Doubles than the fraction based Rational class. We could also add an implementation of infinite precision irrationals using a pair of Integers for exponent and mantissa. That would just be a subset of

Re: [Haskell-cafe] Re: Double - CDouble, realToFrac doesn't work

2004-11-08 Thread Ben Rudiak-Gould
Henning Thielemann wrote: I wonder why Infinity has a sign in IEEE floating processing, as well as 0. To support this behaviour uniformly one would need a +0 or -0 offset for each number, which would lead straightforward to non-standard analysis ... See Branch Cuts for Complex Elementary

Re: [Haskell-cafe] Re: Double - CDouble, realToFrac doesn't work

2004-11-08 Thread Lennart Augustsson
Henning Thielemann wrote: On Fri, 5 Nov 2004, Robert Dockins wrote: What IEEE has done is shoehorned in some values that aren't really numbers into their representation (NaN certainly; one could make a convincing argument that +Inf and -Inf aren't numbers). I wonder why Infinity has a sign in

Re: Double - CDouble, realToFrac doesn't work

2004-11-05 Thread Dylan Thurston
On Thu, Nov 04, 2004 at 08:32:52PM +0100, Sven Panne wrote: It's an old thread, but nothing has really happened yet, so I'd like to restate and expand the question: What should the behaviour of toRational, fromRational, and decodeFloat for NaN and +/-Infinity be? Even if the report is unclear

Re: Double - CDouble, realToFrac doesn't work

2004-11-05 Thread Ketil Malde
With GHCi, I get: Prelude Ratio toRational (1.0/0) :: Ratio Integer

Re: [Haskell-cafe] Re: Double - CDouble, realToFrac doesn't work

2004-11-05 Thread Robert Dockins
My guess is because irrationals can't be represented on a discrete computer (unless you consider a computaion, the limit of which is the irrational number in question). A single irrational might not just be arbitrarily long, but it may have an _infinite_ length representation! What you have

Re: [Haskell-cafe] Re: Double - CDouble, realToFrac doesn't work

2004-11-05 Thread Henning Thielemann
On Fri, 5 Nov 2004, Robert Dockins wrote: What IEEE has done is shoehorned in some values that aren't really numbers into their representation (NaN certainly; one could make a convincing argument that +Inf and -Inf aren't numbers). I wonder why Infinity has a sign in IEEE floating

Re: [Haskell-cafe] Re: Double - CDouble, realToFrac doesn't work

2004-11-05 Thread MR K P SCHUPKE
My guess is because irrationals can't be represented on a discrete computer Well, call it arbitrary precision floating point then. Having built in Integer support, it does seem odd only having Float/Double/Rational... Keean. .. ___

Re: [Haskell-cafe] Re: Double - CDouble, realToFrac doesn't work

2004-11-05 Thread Duncan Coutts
On Fri, 2004-11-05 at 13:57, Henning Thielemann wrote: On Fri, 5 Nov 2004, Robert Dockins wrote: What IEEE has done is shoehorned in some values that aren't really numbers into their representation (NaN certainly; one could make a convincing argument that +Inf and -Inf aren't numbers).

Re: [Haskell-cafe] Re: Double - CDouble, realToFrac doesn't work

2004-11-05 Thread Robert Dockins
[...] Thus (a-b) is not the same as -(b-a) for IEEE floats! Nor is x*0 equal to 0 for every x; nor does x == y imply f(x) == f(y) for every x, y, f; nor is addition or multiplication associative. There aren't many identities that do hold of floating point numbers. Yes, but they DO hold for

Re: [Haskell-cafe] Re: Double - CDouble, realToFrac doesn't work

2004-11-05 Thread Dylan Thurston
On Fri, Nov 05, 2004 at 02:53:01PM +, MR K P SCHUPKE wrote: My guess is because irrationals can't be represented on a discrete computer Well, call it arbitrary precision floating point then. Having built in Integer support, it does seem odd only having Float/Double/Rational... There are

Re: Double - CDouble, realToFrac doesn't work

2004-11-04 Thread Sven Panne
-haskell-users- | [EMAIL PROTECTED] On Behalf Of Sven Panne | Sent: 08 August 2004 17:02 | To: Hal Daume III | Cc: GHC Users Mailing List; Malcom Wallace | Subject: Re: Double - CDouble, realToFrac doesn't work | | Hal Daume III wrote: | [...] | Prelude Foreign.C (0 :: CDouble) / 0 | NaN | Prelude

RE: Double - CDouble, realToFrac doesn't work

2004-08-09 Thread Simon Peyton-Jones
: Double - CDouble, realToFrac doesn't work | | Hal Daume III wrote: | [...] | Prelude Foreign.C (0 :: CDouble) / 0 | NaN | Prelude Foreign.C (0 :: Double) / 0 | NaN | Prelude Foreign.C realToFrac ((0 :: Double) / 0) :: CDouble | -Infinity | | yikes! the NaN got turned into a -Infinity

Re: Double - CDouble, realToFrac doesn't work

2004-08-08 Thread Sven Panne
Hal Daume III wrote: [...] Prelude Foreign.C (0 :: CDouble) / 0 NaN Prelude Foreign.C (0 :: Double) / 0 NaN Prelude Foreign.C realToFrac ((0 :: Double) / 0) :: CDouble -Infinity yikes! the NaN got turned into a -Infinity!!! aside from manually checking for 'strange' Double/CDouble values and

Double - CDouble, realToFrac doesn't work

2004-08-03 Thread Hal Daume III
I need to convert a Double to a CDouble to pass to a C function. In the past, when I've asked how to do this, I'm told: realToFrac. This works in most cases, but recently gave me a problem that took me *forever* to track down: Prelude Foreign.C (0 :: CDouble) / 0 NaN Prelude Foreign.C (0 ::