[Haskell-cafe] Sinus in Haskell
byorgey at gmail.com
Fri Nov 9 14:30:42 EST 2007
On Nov 9, 2007 2:08 PM, Hans van Thiel <hthiel.char at zonnet.nl> wrote:
> Hello All,
> Can anybody explain the results for 1.0, 2.0 and 3.0 times pi below?
> GHCi yields the same results. I did search the Haskell report and my
> text books, but to no avail. Thanks in advance,
> Hans van Thiel
> Hugs> sin (0.0 * pi)
> Hugs> sin (0.5 * pi)
> Hugs> sin (1.0 * pi)
> Hugs> sin (1.5 * pi)
> Hugs> sin (2.0 * pi)
> Hugs> sin (2.5 * pi)
> Hugs> sin (3.0 * pi)
More generally, this is due to the fact that floating-point numbers can only
have finite precision, so a little bit of rounding error is inevitable when
dealing with irrational numbers like pi. This problem is in no way
specific to Haskell.
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Haskell-Cafe