diff --git a/hedgehog/src/Hedgehog/Internal/Range.hs b/hedgehog/src/Hedgehog/Internal/Range.hs index ce599f89..f009275d 100644 --- a/hedgehog/src/Hedgehog/Internal/Range.hs +++ b/hedgehog/src/Hedgehog/Internal/Range.hs @@ -305,8 +305,14 @@ scaleLinear sz0 z0 n0 = n = toInteger n0 + -- @rng@ has magnitude 1 bigger than the biggest diff + -- i.e. it specifies the range the diff can be in [0,rng) + -- with the upper bound being exclusive. + rng = + n - z + signum (n - z) + diff = - ((n - z) * fromIntegral sz) `quot` 99 + (rng * fromIntegral sz) `quot` 100 in fromInteger $ z + diff