Class: Mysql::Random

Inherits:
Object
  • Object
show all
Defined in:
lib/og/vendor/mysql.rb

Instance Method Summary collapse

Constructor Details

#initialize(seed1, seed2) ⇒ Random

Returns a new instance of Random.



1134
1135
1136
1137
1138
# File 'lib/og/vendor/mysql.rb', line 1134

def initialize(seed1, seed2)
  @max_value = 0x3FFFFFFF
  @seed1 = seed1 % @max_value
  @seed2 = seed2 % @max_value
end

Instance Method Details

#rndObject



1140
1141
1142
1143
1144
# File 'lib/og/vendor/mysql.rb', line 1140

def rnd()
  @seed1 = (@seed1*3+@seed2) % @max_value
  @seed2 = (@seed1+@seed2+33) % @max_value
  @seed1.to_f / @max_value
end