Skip to content

Commit

Permalink
Cut non-necessary temps from generate_integer
Browse files Browse the repository at this point in the history
  • Loading branch information
Neil-Aframe committed May 14, 2014
1 parent 7cc3096 commit 84c7f69
Showing 1 changed file with 1 addition and 5 deletions.
6 changes: 1 addition & 5 deletions lib/pool_of_entropy/core_prng.rb
Original file line number Diff line number Diff line change
Expand Up @@ -117,19 +117,15 @@ def read_float *adjustments
def generate_integer top, *adjustments
power = 1
sum = 0
lower_bound = 0
words = []

loop do
words = read_bytes( *adjustments ).unpack('L>*') if words.empty?
sum = 2**32 * sum + words.shift
power *= 2**32
lower_bound = sum * top / power
upper_bound = ( (sum + 1) * top ) / power
break if lower_bound == upper_bound
break lower_bound if lower_bound == ( (sum + 1) * top ) / power
end

lower_bound
end

private
Expand Down

0 comments on commit 84c7f69

Please sign in to comment.