summaryrefslogtreecommitdiff
path: root/testsuite/tests/lib/Numeric/num008.hs
diff options
context:
space:
mode:
Diffstat (limited to 'testsuite/tests/lib/Numeric/num008.hs')
-rw-r--r--testsuite/tests/lib/Numeric/num008.hs57
1 files changed, 57 insertions, 0 deletions
diff --git a/testsuite/tests/lib/Numeric/num008.hs b/testsuite/tests/lib/Numeric/num008.hs
new file mode 100644
index 0000000000..36158240b4
--- /dev/null
+++ b/testsuite/tests/lib/Numeric/num008.hs
@@ -0,0 +1,57 @@
+-- showing/reading floats
+--
+module Main(main) where
+
+import Numeric
+
+main = do
+ let dbls = map (shEFloat (Just 7)) doubles
+ ++ map (shEFloat (Just 0)) doubles
+ ++ map (shEFloat Nothing) doubles
+ ++ map (shFFloat (Just 7)) doubles
+ ++ map (shFFloat (Just 0)) doubles
+ ++ map (shFFloat Nothing) doubles
+ ++ map (shGFloat (Just 7)) doubles
+ ++ map (shGFloat (Just 0)) doubles
+ ++ map (shGFloat Nothing) doubles
+
+ flts = map (shEFloat (Just 7)) floats
+ ++ map (shEFloat (Just 0)) floats
+ ++ map (shEFloat Nothing) floats
+ ++ map (shFFloat (Just 7)) floats
+ ++ map (shFFloat (Just 0)) floats
+ ++ map (shFFloat Nothing) floats
+ ++ map (shGFloat (Just 7)) floats
+ ++ map (shGFloat (Just 0)) floats
+ ++ map (shGFloat Nothing) floats
+
+ putStrLn (unlines dbls)
+ putStrLn (unlines flts)
+ print (map read dbls :: [Double])
+ print (map read flts :: [Double])
+
+shEFloat p f = showEFloat p f ""
+shFFloat p f = showFFloat p f ""
+shGFloat p f = showGFloat p f ""
+
+doubles :: [ Double ]
+doubles = [ 0.0
+ , 420
+ , 42
+ , 4.2
+ , 0.42
+ , 0.042
+ , 1.82173691287639817263897126389712638972163
+ , 1.82173691287639817263897126389712638972163e-300
+ ]
+
+floats :: [ Float ]
+floats = [ 0.0
+ , 420
+ , 42
+ , 4.2
+ , 0.42
+ , 0.042
+ , 1.82173691287639817263897126389712638972163
+ , 1.82173691287639817263897126389712638972163e-300
+ ]