diff options
author | Bart Massey <bart@cs.pdx.edu> | 2013-09-16 11:07:52 -0700 |
---|---|---|
committer | Joachim Breitner <mail@joachim-breitner.de> | 2013-09-17 21:51:52 +0200 |
commit | 3b6efceff655a4a883f33e5b68b08f3010c58d68 (patch) | |
tree | e12640b6ce1bac83f77a3e39a373ce4ad924bcea /libraries/base/Numeric.hs | |
parent | 8f9f1009b89a54bcab8354a255f1372803f780ce (diff) | |
download | haskell-3b6efceff655a4a883f33e5b68b08f3010c58d68.tar.gz |
Replaced Text.Printf with extensible printf, and made comcommitant changes
Signed-off-by: Joachim Breitner <mail@joachim-breitner.de>
Diffstat (limited to 'libraries/base/Numeric.hs')
-rw-r--r-- | libraries/base/Numeric.hs | 26 |
1 files changed, 23 insertions, 3 deletions
diff --git a/libraries/base/Numeric.hs b/libraries/base/Numeric.hs index 600c82f8ec..88b2e1a063 100644 --- a/libraries/base/Numeric.hs +++ b/libraries/base/Numeric.hs @@ -6,7 +6,7 @@ -- Module : Numeric -- Copyright : (c) The University of Glasgow 2002 -- License : BSD-style (see the file libraries/base/LICENSE) --- +-- -- Maintainer : libraries@haskell.org -- Stability : provisional -- Portability : portable @@ -30,6 +30,8 @@ module Numeric ( showEFloat, showFFloat, showGFloat, + showFFloatAlt, + showGFloatAlt, showFloat, floatToDigits, @@ -89,7 +91,7 @@ readDec = readP_to_S L.readDecP -- | Read an unsigned number in hexadecimal notation. -- Both upper or lower case letters are allowed. readHex :: (Eq a, Num a) => ReadS a -readHex = readP_to_S L.readHexP +readHex = readP_to_S L.readHexP -- | Reads an /unsigned/ 'RealFrac' value, -- expressed in decimal scientific notation. @@ -168,7 +170,7 @@ showEFloat :: (RealFloat a) => Maybe Int -> a -> ShowS showFFloat :: (RealFloat a) => Maybe Int -> a -> ShowS -- | Show a signed 'RealFloat' value --- using standard decimal notation for arguments whose absolute value lies +-- using standard decimal notation for arguments whose absolute value lies -- between @0.1@ and @9,999,999@, and scientific notation otherwise. -- -- In the call @'showGFloat' digs val@, if @digs@ is 'Nothing', @@ -180,6 +182,24 @@ showEFloat d x = showString (formatRealFloat FFExponent d x) showFFloat d x = showString (formatRealFloat FFFixed d x) showGFloat d x = showString (formatRealFloat FFGeneric d x) +-- | Show a signed 'RealFloat' value +-- using standard decimal notation (e.g. @245000@, @0.0015@). +-- +-- This behaves as 'showFFloat', except that a decimal point +-- is always guaranteed, even if not needed. +showFFloatAlt :: (RealFloat a) => Maybe Int -> a -> ShowS + +-- | Show a signed 'RealFloat' value +-- using standard decimal notation for arguments whose absolute value lies +-- between @0.1@ and @9,999,999@, and scientific notation otherwise. +-- +-- This behaves as 'showFFloat', except that a decimal point +-- is always guaranteed, even if not needed. +showGFloatAlt :: (RealFloat a) => Maybe Int -> a -> ShowS + +showFFloatAlt d x = showString (formatRealFloatAlt FFFixed d True x) +showGFloatAlt d x = showString (formatRealFloatAlt FFGeneric d True x) + -- --------------------------------------------------------------------------- -- Integer printing functions |