repo.or.cz
/
ruby-svn.git
/
blob
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
log
|
graphiclog1
|
graphiclog2
|
commit
|
commitdiff
|
tree
|
refs
|
edit
|
fork
history
|
raw
|
HEAD
add rdoc.
[ruby-svn.git]
/
benchmark
/
bm_so_random.rb
blob
83c0d6d380e4162a201072a71aa35601dc6cb932
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 = 1000000
14
15
i=0
16
while i<N
17
i+=1
18
gen_random(100.0)
19
end
20
# "%.9f" % gen_random(100.0)