File: num008.hs

package info (click to toggle)
ghc 8.0.1-17
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 55,080 kB
  • ctags: 9,332
  • sloc: haskell: 363,120; ansic: 54,900; sh: 4,782; makefile: 974; perl: 542; asm: 315; python: 306; xml: 154; lisp: 7
file content (57 lines) | stat: -rw-r--r-- 1,672 bytes parent folder | download | duplicates (12)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
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
          ]