diff --git a/diversity.cabal b/diversity.cabal
--- a/diversity.cabal
+++ b/diversity.cabal
@@ -2,7 +2,7 @@
 -- documentation, see http://haskell.org/cabal/users-guide/
 
 name:                diversity
-version:             0.6.2.1
+version:             0.6.3.0
 synopsis:            Return the diversity at each position for all sequences in a fasta file
 description:         Find the diversity of a collection of entities, mainly for use with fasta sequences. Produces a binary which works on fasta files to find the diversity of any order and rarefaction curves for a sliding window across all positions in the sequences. To analyze just a collection of entities, just use the whole sequences and list flag.
 homepage:            https://github.com/GregorySchwartz/diversity
diff --git a/src/src-lib/Math/Diversity/Diversity.hs b/src/src-lib/Math/Diversity/Diversity.hs
--- a/src/src-lib/Math/Diversity/Diversity.hs
+++ b/src/src-lib/Math/Diversity/Diversity.hs
@@ -229,7 +229,9 @@
 -- | Returns the number of individuals needed to get the proportion g of
 -- the estimated total richness of the assemblage. Sobs / Sest < g < 1
 individualG :: Double -> Map.Map (Sample, Fragment) Int -> Double
-individualG g sample = ((sobs * f1) / (2 * f2)) * log (f0 / ((1 - g) * sest))
+individualG g sample
+    | sobs / sest >= g = 0
+    | otherwise = ((sobs * f1) / (2 * f2)) * log (f0 / ((1 - g) * sest))
   where
     sest = sobs + f0
     sobs = fromIntegral $ richness sample
@@ -240,8 +242,10 @@
 -- | Returns the number of samples needed to get the proportion g of
 -- the estimated total richness of the assemblage. Sobs / Sest < g < 1
 sampleG :: Double -> Map.Map (Sample, Fragment) Int -> Double
-sampleG g sample = log (1 - ((t / (t - 1)) * ((2 * q2) / (q1 ** 2)) * ((g * sest) - sobs)))
-                 / log (1 - ((2 * q2) / (((t - 1) * q1) + (2 * q2))))
+sampleG g sample
+    | sobs / sest >= g = 0
+    | otherwise = log (1 - ((t / (t - 1)) * ((2 * q2) / (q1 ** 2)) * ((g * sest) - sobs)))
+                / log (1 - ((2 * q2) / (((t - 1) * q1) + (2 * q2))))
   where
     t    = fromIntegral . Map.size . Map.mapKeys fst $ sample
     sest = sobs + q0
