Commit 7dc97329 authored by Ian Lynagh's avatar Ian Lynagh
Browse files

Add a test for Integer-Float/Double conversions

parent e0248bf9
......@@ -7,3 +7,4 @@ test('num006', normal, compile_and_run, [''])
test('num007', normal, compile_and_run, [''])
test('num008', normal, compile_and_run, [''])
test('num009', normal, compile_and_run, [''])
test('num010', normal, compile_and_run, [''])
module Main(main) where
main = sequence_ [ f x y | x <- [0,
1000,
1000000000000, -- > 2^32
1000000000000000000000000, -- > 2^64
-1000,
-1000000000000, -- < -2^32
-1000000000000000000000000] -- < -2^64
, y <- [0, -10, 10] ]
f :: Integer -> Int -> IO ()
f x y = do putStrLn "------------------------"
print x
print y
let d :: Double
d = encodeFloat x y
(xd, yd) = decodeFloat d
let f :: Float
f = encodeFloat x y
(xf, yf) = decodeFloat f
print d
print xd
print yd
print f
print xf
print yf
------------------------
0
0
0.0
0
0
0.0
0
0
------------------------
0
-10
0.0
0
0
0.0
0
0
------------------------
0
10
0.0
0
0
0.0
0
0
------------------------
1000
0
1000.0
8796093022208000
-43
1000.0
16384000
-14
------------------------
1000
-10
0.9765625
8796093022208000
-53
0.9765625
16384000
-24
------------------------
1000
10
1024000.0
8796093022208000
-33
1024000.0
16384000
-4
------------------------
1000000000000
0
1.0e12
8192000000000000
-13
1.0e12
15258789
16
------------------------
1000000000000
-10
9.765625e8
8192000000000000
-23
9.765625e8
15258789
6
------------------------
1000000000000
10
1.024e15
8192000000000000
-3
1.024e15
15258789
26
------------------------
1000000000000000000000000
0
1.0e24
7450580596923828
27
1.0e24
13877788
56
------------------------
1000000000000000000000000
-10
9.765625e20
7450580596923828
17
9.765625e20
13877788
46
------------------------
1000000000000000000000000
10
1.024e27
7450580596923828
37
1.024e27
13877788
66
------------------------
-1000
0
-1000.0
-8796093022208000
-43
-1000.0
-16384000
-14
------------------------
-1000
-10
-0.9765625
-8796093022208000
-53
-0.9765625
-16384000
-24
------------------------
-1000
10
-1024000.0
-8796093022208000
-33
-1024000.0
-16384000
-4
------------------------
-1000000000000
0
-1.0e12
-8192000000000000
-13
-1.0e12
-15258789
16
------------------------
-1000000000000
-10
-9.765625e8
-8192000000000000
-23
-9.765625e8
-15258789
6
------------------------
-1000000000000
10
-1.024e15
-8192000000000000
-3
-1.024e15
-15258789
26
------------------------
-1000000000000000000000000
0
-1.0e24
-7450580596923828
27
-1.0e24
-13877788
56
------------------------
-1000000000000000000000000
-10
-9.765625e20
-7450580596923828
17
-9.765625e20
-13877788
46
------------------------
-1000000000000000000000000
10
-1.024e27
-7450580596923828
37
-1.024e27
-13877788
66
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment