[project @ 1999-01-24 14:18:55 by sof]
[ghc-hetmet.git] / ghc / tests / numeric / should_run / arith005.hs
1 -- !!! test RealFrac ops (ceiling/floor/etc.) on Floats/Doubles
2 --
3 main = 
4  putStr $
5   unlines
6     [  -- just for fun, we show the floats to
7        -- exercise the code responsible.
8       show (float_list :: [Float])
9     , show (double_list :: [Double])
10        -- {Float,Double} inputs, {Int,Integer} outputs
11     , show ((map ceiling float_list) :: [Int])
12     , show ((map ceiling float_list) :: [Integer])
13     , show ((map ceiling double_list) :: [Int])
14     , show ((map ceiling double_list) :: [Integer])
15     , show ((map floor float_list) :: [Int])
16     , show ((map floor float_list) :: [Integer])
17     , show ((map floor double_list) :: [Int])
18     , show ((map floor double_list) :: [Integer])
19     , show ((map truncate float_list) :: [Int])
20     , show ((map truncate float_list) :: [Integer])
21     , show ((map truncate double_list) :: [Int])
22     , show ((map truncate double_list) :: [Integer])
23 {-
24     , show ((map round float_list) :: [Int])
25 -}
26     , show ((map round float_list) :: [Integer])
27     , show ((map round double_list) :: [Int])
28     , show ((map round double_list) :: [Integer])
29     , show ((map properFraction float_list) :: [(Int,Float)])
30     , show ((map properFraction float_list) :: [(Integer,Float)])
31     , show $ head ((map properFraction double_list) :: [(Int,Double)])
32 {-
33     , show ((map properFraction double_list) :: [(Integer,Double)])
34 -}
35     ]
36   where
37     float_list :: [Float]
38     float_list = [
39         0.0, -0.0, 1.1, 2.8, 3.5, 4.5, -1.0000000001, -2.9999995,
40         -3.50000000001, -4.49999999999, 1000012.0, 123.456, 100.25,
41         102.5, 0.0012, -0.00000012, 1.7e4, -1.7e-4, 0.15e-6, pi,
42         1.18088e+11,    1.2111e+14 
43       ]
44
45     double_list :: [Double]
46     double_list = [
47         0.0, -0.0, 1.1, 2.8, 3.5, 4.5, -1.0000000001, -2.9999995,
48         -3.50000000001, -4.49999999999, 1000012.0, 123.456, 100.25,
49         102.5, 0.0012, -0.00000012, 1.7e4, -1.7e-4, 0.15e-6, pi,
50         1.18088e+11,    1.2111e+14 
51       ]