2 % (c) The AQUA Project, Glasgow University, 1997-98
4 \section[Numeric]{Numeric interface}
6 Odds and ends, mostly functions for reading and showing
7 \tr{RealFloat}-like kind of values.
11 {-# OPTIONS -fno-implicit-prelude #-}
20 readDec, readOct, readHex,
39 import PrelErr ( error )
43 %*********************************************************
45 \subsection[Numeric-signatures]{Signatures}
47 %*********************************************************
52 fromRat :: (RealFloat a) => Rational -> a
54 showSigned :: (Real a) => (a -> ShowS) -> Int -> a -> ShowS
55 readSigned :: (Real a) => ReadS a -> ReadS a
57 showInt :: Integral a => a -> ShowS
58 readInt :: (Integral a) => a -> (Char -> Bool) -> (Char -> Int) -> ReadS a
60 readDec :: (Integral a) => ReadS a
61 readOct :: (Integral a) => ReadS a
62 readHex :: (Integral a) => ReadS a
64 showEFloat :: (RealFloat a) => Maybe Int -> a -> ShowS
65 showFFloat :: (RealFloat a) => Maybe Int -> a -> ShowS
66 showGFloat :: (RealFloat a) => Maybe Int -> a -> ShowS
67 showFloat :: (RealFloat a) => a -> ShowS
69 readFloat :: (RealFloat a) => ReadS a
71 floatToDigits :: (RealFloat a) => Integer -> a -> ([Int], Int)
72 lexDigits :: ReadS String
76 showInt :: Integral a => a -> ShowS
78 | n < 0 = error "Numeric.showInt: can't show negative numbers"
82 case quotRem n 10 of { (n', d) ->
83 case chr (ord_0 + fromIntegral d) of { C# c# -> -- stricter than necessary
87 if n' == 0 then r' else go n' r'
91 Controlling the format and precision of floats. The code that
92 implements the formatting itself is in @PrelNum@ to avoid
96 showEFloat :: (RealFloat a) => Maybe Int -> a -> ShowS
97 showFFloat :: (RealFloat a) => Maybe Int -> a -> ShowS
98 showGFloat :: (RealFloat a) => Maybe Int -> a -> ShowS
100 showEFloat d x = showString (formatRealFloat FFExponent d x)
101 showFFloat d x = showString (formatRealFloat FFFixed d x)
102 showGFloat d x = showString (formatRealFloat FFGeneric d x)