Class: Mysql::Random
- Inherits:
-
Object
- Object
- Mysql::Random
- Defined in:
- lib/og/vendor/mysql.rb
Instance Method Summary collapse
-
#initialize(seed1, seed2) ⇒ Random
constructor
A new instance of Random.
- #rnd ⇒ Object
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
#rnd ⇒ Object
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 |