diff --git a/Control/Monad/CryptoRandom.hs b/Control/Monad/CryptoRandom.hs
--- a/Control/Monad/CryptoRandom.hs
+++ b/Control/Monad/CryptoRandom.hs
@@ -162,8 +162,8 @@
         in case offset of
         Left err -> Left err
         Right (bs, g') ->
-                let res = fromIntegral $ fromIntegral low + (bs2i bs .&. mask)
-                in if res > high then go g' else Right (res, g')
+		let res = fromIntegral low + (bs2i bs .&. mask)
+		in if res > fromIntegral high then go g' else Right (fromIntegral res, g')
 {-# INLINE crandomR_Num #-}
 
 wrap :: (Monad m, ContainsGenError e, Error e) => (g -> Either GenError (a,g)) -> CRandT g e m a
diff --git a/monadcryptorandom.cabal b/monadcryptorandom.cabal
--- a/monadcryptorandom.cabal
+++ b/monadcryptorandom.cabal
@@ -1,5 +1,5 @@
 name:           monadcryptorandom
-version:        0.4
+version:        0.4.1
 license:        BSD3
 license-file:   LICENSE
 copyright:      Thomas DuBuisson <thomas.dubuisson@gmail.com>
