RandomGNUSmalltalk.st
changeset 5251 567f7b09329b
parent 4610 73aae1b4cc57
equal deleted inserted replaced
5250:835883130a92 5251:567f7b09329b
   130 
   130 
   131 maxInteger
   131 maxInteger
   132     ^ modulus
   132     ^ modulus
   133 !
   133 !
   134 
   134 
   135 next
       
   136     "return the next random number in the range ]0..1["
       
   137 
       
   138     self step.
       
   139     ^ seed / modulus asFloat
       
   140 
       
   141     "
       
   142      |r|
       
   143      r := Random new.
       
   144      Transcript showCR:r next.
       
   145      Transcript showCR:r next.
       
   146      Transcript showCR:r next.
       
   147      Transcript showCR:r next.
       
   148     "
       
   149 
       
   150     "Modified: 1.4.1997 / 22:44:46 / cg"
       
   151 !
       
   152 
       
   153 nextBoolean
   135 nextBoolean
   154     "return true or false by random"
   136     "return true or false by random"
   155 
   137 
   156     self step.
   138     self step.
   157     ^ seed < (modulus // 2)
   139     ^ seed < (modulus // 2)
   229 
   211 
   230     "Created: 1.4.1997 / 22:40:45 / cg"
   212     "Created: 1.4.1997 / 22:40:45 / cg"
   231     "Modified: 1.4.1997 / 22:43:01 / cg"
   213     "Modified: 1.4.1997 / 22:43:01 / cg"
   232 ! !
   214 ! !
   233 
   215 
       
   216 !RandomGNUSmalltalk methodsFor:'reading'!
       
   217 
       
   218 next
       
   219     "return the next random number in the range ]0..1["
       
   220 
       
   221     self step.
       
   222     ^ seed / modulus asFloat
       
   223 
       
   224     "
       
   225      |r|
       
   226      r := Random new.
       
   227      Transcript showCR:r next.
       
   228      Transcript showCR:r next.
       
   229      Transcript showCR:r next.
       
   230      Transcript showCR:r next.
       
   231     "
       
   232 
       
   233     "Modified: 1.4.1997 / 22:44:46 / cg"
       
   234 ! !
       
   235 
   234 !RandomGNUSmalltalk class methodsFor:'documentation'!
   236 !RandomGNUSmalltalk class methodsFor:'documentation'!
   235 
   237 
   236 version
   238 version
   237     ^ '$Header$'
   239     ^ '$Header$'
   238 !
   240 !