diff --git a/hledger-lib/Hledger/Data/Amount.hs b/hledger-lib/Hledger/Data/Amount.hs index f45cbc3c7..a75909dcc 100644 --- a/hledger-lib/Hledger/Data/Amount.hs +++ b/hledger-lib/Hledger/Data/Amount.hs @@ -101,11 +101,7 @@ module Hledger.Data.Amount ( ) where import Data.Char (isDigit) -#ifdef DOUBLE -roundTo = flip const -#else import Data.Decimal (roundTo) -#endif import Data.Function (on) import Data.List import Data.Map (findWithDefault) @@ -211,16 +207,8 @@ isZeroAmount a -- a==missingamt = False | otherwise = (null . filter (`elem` digits) . showAmountWithoutPriceOrCommodity) a -- | Is this amount "really" zero, regardless of the display precision ? --- Since we are using floating point, for now just test to some high precision. isReallyZeroAmount :: Amount -> Bool -isReallyZeroAmount Amount{aquantity=q} = iszero q - where - iszero = -#ifdef DOUBLE - null . filter (`elem` digits) . printf ("%."++show zeroprecision++"f") where zeroprecision = 8 -#else - (==0) -#endif +isReallyZeroAmount Amount{aquantity=q} = q == 0 -- | Get the string representation of an amount, based on its commodity's -- display settings except using the specified precision. @@ -292,15 +280,9 @@ showamountquantity Amount{aquantity=q, astyle=AmountStyle{asprecision=p, asdecim where -- isint n = fromIntegral (round n) == n qstr -- p == maxprecision && isint q = printf "%d" (round q::Integer) -#ifdef DOUBLE - | p == maxprecisionwithpoint = printf "%f" q - | p == maxprecision = chopdotzero $ printf "%f" q - | otherwise = printf ("%."++show p++"f") q -#else | p == maxprecisionwithpoint = show q | p == maxprecision = chopdotzero $ show q | otherwise = show $ roundTo (fromIntegral p) q -#endif -- | Replace a number string's decimal point with the specified character, -- and add the specified digit group separators. The last digit group will diff --git a/hledger-lib/Hledger/Data/Types.hs b/hledger-lib/Hledger/Data/Types.hs index 1aaaa462b..6e85df171 100644 --- a/hledger-lib/Hledger/Data/Types.hs +++ b/hledger-lib/Hledger/Data/Types.hs @@ -24,10 +24,8 @@ import GHC.Generics (Generic) import Control.DeepSeq (NFData) import Control.Monad.Except (ExceptT) import Data.Data -#ifndef DOUBLE import Data.Decimal import Text.Blaze (ToMarkup(..)) -#endif import qualified Data.Map as M import Data.Time.Calendar import Data.Time.LocalTime @@ -64,13 +62,7 @@ data Side = L | R deriving (Eq,Show,Read,Ord,Typeable,Data,Generic) instance NFData Side --- | The basic numeric type used in amounts. Different implementations --- can be selected via cabal flag for testing and benchmarking purposes. -numberRepresentation :: String -#ifdef DOUBLE -type Quantity = Double -numberRepresentation = "Double" -#else +-- | The basic numeric type used in amounts. type Quantity = Decimal deriving instance Data (Quantity) -- The following is for hledger-web, and requires blaze-markup. @@ -78,8 +70,6 @@ deriving instance Data (Quantity) instance ToMarkup (Quantity) where toMarkup = toMarkup . show -numberRepresentation = "Decimal" -#endif -- | An amount's price (none, per unit, or total) in another commodity. -- Note the price should be a positive number, although this is not enforced. diff --git a/hledger-lib/hledger-lib.cabal b/hledger-lib/hledger-lib.cabal index 7e948c5ab..6f5f692e9 100644 --- a/hledger-lib/hledger-lib.cabal +++ b/hledger-lib/hledger-lib.cabal @@ -61,8 +61,6 @@ flag old-locale if true then depend on time < 1.5 together with old-locale. library - if flag(double) - cpp-options: -DDOUBLE ghc-options: -Wall -fno-warn-unused-do-bind -fno-warn-name-shadowing -fno-warn-missing-signatures -fno-warn-type-defaults -fno-warn-orphans build-depends: base >= 4.3 && < 5 diff --git a/hledger/Hledger/Cli/Version.hs b/hledger/Hledger/Cli/Version.hs index 9fed1ea7a..2e73f28a7 100644 --- a/hledger/Hledger/Cli/Version.hs +++ b/hledger/Hledger/Cli/Version.hs @@ -14,7 +14,6 @@ where import System.Info (os, arch) import Text.Printf -import Hledger.Data.Types (numberRepresentation) import Hledger.Utils @@ -27,7 +26,7 @@ version = VERSION version = "dev build" #endif prognameandversion = progname ++ " " ++ version -prognameanddetailedversion = printf "%s %s, using %s" progname version numberRepresentation +prognameanddetailedversion = printf "%s %s" progname version -- developer build version strings include PATCHLEVEL (number of -- patches since the last tag). If defined, it must be a number.