[project @ 2003-09-23 10:09:17 by panne]
[ghc-base.git] / Numeric.hs
index 75c7b47..d55f9bb 100644 (file)
@@ -30,7 +30,6 @@ module Numeric (
         showIntAtBase,    -- :: Integral a => a -> (a -> Char) -> a -> ShowS
         showHex,          -- :: Integral a => a -> ShowS
         showOct,          -- :: Integral a => a -> ShowS
-        showBin,          -- :: Integral a => a -> ShowS
 
        showEFloat,       -- :: (RealFloat a) => Maybe Int -> a -> ShowS
        showFFloat,       -- :: (RealFloat a) => Maybe Int -> a -> ShowS
@@ -58,6 +57,7 @@ import qualified Text.Read.Lex as L
 #endif
 
 #ifdef __HUGS__
+import Hugs.Prelude
 import Hugs.Numeric
 #endif
 
@@ -141,12 +141,12 @@ showGFloat d x =  showString (formatRealFloat FFGeneric d x)
 -- ---------------------------------------------------------------------------
 -- Integer printing functions
 
-showIntAtBase :: Integral a => a -> (a -> Char) -> a -> ShowS
+showIntAtBase :: Integral a => a -> (Int -> Char) -> a -> ShowS
 showIntAtBase base toChr n r
   | n < 0  = error ("Numeric.showIntAtBase: applied to negative number " ++ show n)
   | otherwise = 
     case quotRem n base of { (n', d) ->
-    let c = toChr d in
+    let c = toChr (fromIntegral d) in
     seq c $ -- stricter than necessary
     let
        r' = c : r
@@ -154,23 +154,6 @@ showIntAtBase base toChr n r
     if n' == 0 then r' else showIntAtBase base toChr n' r'
     }
 
-showHex :: Integral a => a -> ShowS
-showHex n r = 
- showString "0x" $
- showIntAtBase 16 (toChrHex) n r
- where  
-  toChrHex d
-    | d < 10    = chr (ord '0' + fromIntegral d)
-    | otherwise = chr (ord 'a' + fromIntegral (d - 10))
-
-showOct :: Integral a => a -> ShowS
-showOct n r = 
- showString "0o" $
- showIntAtBase 8 (toChrOct) n r
- where toChrOct d = chr (ord '0' + fromIntegral d)
-
-showBin :: Integral a => a -> ShowS
-showBin n r = 
- showString "0b" $
- showIntAtBase 2 (toChrOct) n r
- where toChrOct d = chr (ord '0' + fromIntegral d)
+showHex, showOct :: Integral a => a -> ShowS
+showHex = showIntAtBase 16 intToDigit
+showOct = showIntAtBase 8  intToDigit