> But this brings up a strange thing in GHCi. Suppose I load
> the following module into GHCi:
>
> \begin{code}
> module Foo where
>
> kalle = (fromRational ((toRational 4) - ( toRational 5.2 )))
>
> default (Rational)
> \end{code}
>
> What happens is the following:
>
> Prelude> :l Foo.hs
>
On Wed, 13 Nov 2002, Jan Kort wrote:
>
> Juan Ignacio Garcia Garcia wrote:
> > *P2> (fromRational ((toRational 4) - ( toRational 5.2 )))
> > -1.2002
>
> I can't explain this one, how would fromRational
> know that it has to create a Double ?
>
It's the defaulting mechanism that kicks i
Juan Ignacio Garcia Garcia wrote:
> *P2> (fromRational ((toRational 4) - ( toRational 5.2 )))
> -1.2002
I can't explain this one, how would fromRational
know that it has to create a Double ?
Jan
___
Glasgow-haskell-users mailing list
[EMA
If that is a serious question, then the answer is that if you want to take
advantage of floating point hardware you are in general limited to those
representations that the hardware understands.
Also, most floating point representations have a binary field for what is
effectively the significan
Lennart Augustsson wrote:
> The number 5.2 is stored
as a slightly different number as a Float, but the toRational function
is exact
so it gives you the number corresponding to the internal representation.
Take a course on numerical analysis. :)
Nope. Take a course entitled:
Why all you zomb
Yes, they all seem to be right.
You get these funny effects because numbers like 5.2 do not have an
exact representation with floating point numbers in base to (like Float
and Double most likely have on your machine). The number 5.2 is stored
as a slightly different number as a Float, but the toRa
> I have been using some of the functions of the classes Real and
> Fractional and I have observed that with the funcion
> "toRational" we can
> obtain the fraction that represents a given number. For instance:
> *P2> toRational (5.2::Float)
> 5452595 % 1048576
> Why we obtain this numbers inst