diff --git a/src/NumericUtils.hs b/src/NumericUtils.hs
--- a/src/NumericUtils.hs
+++ b/src/NumericUtils.hs
@@ -7,6 +7,8 @@
     ) where
 
 import Data.Char
+import Data.Foldable
+import Data.Ord
 import GHC.Base
 import GHC.Float (FFFormat(..), roundTo)
 import Numeric (floatToDigits)
@@ -37,8 +39,8 @@
         if x < 0
             then "-Infinity"
             else "Infinity"
-    | x < 0 || isNegativeZero x = '-' : doFmt fmt (floatToDigits (toInteger base) (-x))
-    | otherwise = doFmt fmt (floatToDigits (toInteger base) x)
+    | x < 0 || isNegativeZero x = '-' : doFmt fmt (floatToDigits base (-x))
+    | otherwise = doFmt fmt (floatToDigits base x)
   where
     eChar
         | upper = 'E'
@@ -48,11 +50,9 @@
         let ds = map intToDigit is
          in case format of
                 FFGeneric ->
-                    let alt1 = doFmt FFExponent (is, e)
-                        alt2 = doFmt FFFixed (is, e)
-                     in if length alt2 > length alt1
-                            then alt1
-                            else alt2
+                    minimumBy
+                        (comparing length)
+                        [doFmt FFExponent (is, e), doFmt FFFixed (is, e)]
                 FFExponent ->
                     case decs of
                         Nothing ->
@@ -139,7 +139,7 @@
                               else b)
             Nothing -> \x -> ('1', x)
     doFmt ([0], 0) = "0" ++ [pChar] ++ "+0"
-    doFmt ((1:bits), exp) =
+    doFmt ((_:bits), exp) =
         first :
         (if null digs && not alt
              then ""
diff --git a/src/Text/Printf/TH.hs b/src/Text/Printf/TH.hs
--- a/src/Text/Printf/TH.hs
+++ b/src/Text/Printf/TH.hs
@@ -57,7 +57,7 @@
 --
 -- %?     :: 'Show' a => a
 --
--- %u     :: 'GHC.Natural.Natural'
+-- %u     :: 'Numeric.Natural.Natural'
 --
 -- %d, %i :: 'Integral' i => i
 -- %o     :: 'Integral' i => i
diff --git a/th-printf.cabal b/th-printf.cabal
--- a/th-printf.cabal
+++ b/th-printf.cabal
@@ -1,5 +1,5 @@
 name:          th-printf
-version:       0.5.0
+version:       0.5.1
 synopsis:      Compile-time printf
 description:   Quasiquoters for printf: string, bytestring, text.
 license:       MIT
@@ -9,7 +9,7 @@
 category:      Text
 homepage:      https://github.com/pikajude/th-printf
 build-type:    Simple
-cabal-version: >=1.10
+cabal-version: >= 1.10
 
 source-repository head
   type:     git
@@ -23,9 +23,7 @@
                       Text.Printf.TH.Printer.String
                       Text.Printf.TH.Types
   hs-source-dirs:     src
-  default-language:   Haskell2010
-  default-extensions: NoMonomorphismRestriction
-  build-depends:      base             >= 4.8 && < 4.11
+  build-depends:      base             >= 4.8 && < 5
                     , ansi-wl-pprint
                     , attoparsec
                     , charset
@@ -35,6 +33,8 @@
                     , transformers
                     , trifecta
                     , utf8-string
+  default-language:   Haskell2010
+  default-extensions: NoMonomorphismRestriction
   ghc-options:        -Wall -fno-warn-missing-signatures -fno-warn-name-shadowing
                       -fno-warn-unused-do-bind
 
@@ -43,7 +43,6 @@
   main-is:          format.hs
   other-modules:    Codegen
   hs-source-dirs:   tests
-  default-language: Haskell2010
   build-depends:    base
                   , HUnit
                   , QuickCheck
@@ -52,13 +51,13 @@
                   , template-haskell
                   , text
                   , th-printf
+  default-language: Haskell2010
   ghc-options:      -Wall -fno-warn-type-defaults
 
 benchmark perf
   type:             exitcode-stdio-1.0
   main-is:          benchmark.hs
   hs-source-dirs:   benchmark
-  default-language: Haskell2010
   build-depends:    base, criterion, text, th-printf
+  default-language: Haskell2010
   ghc-options:      -O2 -Wall -fno-warn-type-defaults
-
