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,
38 import PrelErr ( error )
42 %*********************************************************
44 \subsection[Numeric-signatures]{Signatures}
46 %*********************************************************
51 fromRat :: (RealFloat a) => Rational -> a
53 showSigned :: (Real a) => (a -> ShowS) -> Int -> a -> ShowS
54 readSigned :: (Real a) => ReadS a -> ReadS a
56 showInt :: Integral a => a -> ShowS
57 readInt :: (Integral a) => a -> (Char -> Bool) -> (Char -> Int) -> ReadS a
59 readDec :: (Integral a) => ReadS a
60 readOct :: (Integral a) => ReadS a
61 readHex :: (Integral a) => ReadS a
63 showEFloat :: (RealFloat a) => Maybe Int -> a -> ShowS
64 showFFloat :: (RealFloat a) => Maybe Int -> a -> ShowS
65 showGFloat :: (RealFloat a) => Maybe Int -> a -> ShowS
66 showFloat :: (RealFloat a) => a -> ShowS
68 readFloat :: (RealFloat a) => ReadS a
70 floatToDigits :: (RealFloat a) => Integer -> a -> ([Int], Int)
71 lexDigits :: ReadS String
75 showInt :: Integral a => a -> ShowS
77 | n < 0 = error "Numeric.showInt: can't show negative numbers"
81 case quotRem n 10 of { (n', d) ->
82 case chr (ord_0 + fromIntegral d) of { C# c# -> -- stricter than necessary
86 if n' == 0 then r' else go n' r'
90 Controlling the format and precision of floats. The code that
91 implements the formatting itself is in @PrelNum@ to avoid
95 showEFloat :: (RealFloat a) => Maybe Int -> a -> ShowS
96 showFFloat :: (RealFloat a) => Maybe Int -> a -> ShowS
97 showGFloat :: (RealFloat a) => Maybe Int -> a -> ShowS
99 showEFloat d x = showString (formatRealFloat FFExponent d x)
100 showFFloat d x = showString (formatRealFloat FFFixed d x)
101 showGFloat d x = showString (formatRealFloat FFGeneric d x)