repo.or.cz
/
ruby.git
/
blob
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
log
|
graphiclog1
|
graphiclog2
|
commit
|
commitdiff
|
tree
|
refs
|
edit
|
fork
history
|
raw
|
HEAD
[rubygems/rubygems] Use a constant empty tar header to avoid extra allocations
[ruby.git]
/
benchmark
/
so_random.rb
blob
a66b9e8e63303c0a970219bf073bbfe17f8d06af
1
# from http://www.bagley.org/~doug/shootout/bench/random/random.ruby
2
3
IM = 139968.0
4
IA = 3877.0
5
IC = 29573.0
6
7
$last = 42.0
8
9
def gen_random(max)
10
(max * ($last = ($last * IA + IC) % IM)) / IM
11
end
12
13
N = 3_000_000
14
15
i = 0
16
while i<N
17
i +=1
18
gen_random(100.0)
19
end
20
# "%.9f" % gen_random(100.0)