The precission and or rounding used by hugs/ghc seems strange, to wit:
Prelude> sin(pi)
-8.74228e-08
Prelude> pi
3.14159
sin(3.14159265358979323846)
-8.74228e-08
ghc:
module Main where
main = do
print pi
print (sin pi)
./a.out
3.141592653589793
1.2246467991473532e-16
While this maybe accurate in terms of ieee foat and double, most maths
libraries round if a value is `close' to a small integer (such as 1,
0, -1), inorder to avoid amplification of missing precission during
iterative processes.
#include <math.h>
#include <stdio.h>
main(){
printf("sin(%f) = %f\n", M_PI, sin(M_PI));
}
M_PI is defined by <math.h> as 3.14159265358979323846
./a.out
sin(3.141593) = 0.000000
Cheers,
Julian.
--
Warren Air Force Base in Cheyenne, Wyoming, recorded a message that
one of its Minuteman III intercontinental ballistic missiles was
about to launch from its silo due to a computer malfunction. To
prevent the possible launch, an armored car was parked on top of
the silo.
- Shaun Gregory, The Hidden Cost of Deterrence: Nuclear Weapons
Accidents, Brassey's UK, London, 1990, pp. 181-182.