--- a/RandomGenerator.st Thu Oct 01 17:24:02 2015 +0200
+++ b/RandomGenerator.st Thu Oct 01 19:04:41 2015 +0200
@@ -1,3 +1,5 @@
+"{ Encoding: utf8 }"
+
"
COPYRIGHT (c) 2007 by eXept Software AG
All Rights Reserved
@@ -11,6 +13,8 @@
"
"{ Package: 'stx:libbasic2' }"
+"{ NameSpace: Smalltalk }"
+
Random subclass:#RandomGenerator
instanceVariableNames:''
classVariableNames:'RandFile SharedRandomGenerator'
@@ -174,6 +178,9 @@
^ OperatingSystem randomBytesInto:1.
].
+ RandFile isOpen ifFalse:[
+ self class openRandFile.
+ ].
^ RandFile nextByte
"
@@ -202,6 +209,9 @@
RandFile == true ifTrue:[
^ OperatingSystem randomBytesInto:(ByteArray new:cnt).
].
+ RandFile isOpen ifFalse:[
+ self class openRandFile.
+ ].
^ RandFile nextBytes:cnt.
"
@@ -210,33 +220,6 @@
"Created: / 11.11.1999 / 09:25:39 / stefan"
"Modified: / 11.11.1999 / 09:52:26 / stefan"
-!
-
-nextInteger
- "return the next integral random number,
- in the range 0 .. 16r3FFFFFFF."
-
- |res|
-
- RandFile == true ifTrue:[
- ^ OperatingSystem randomBytesInto:4.
- ].
-
- res := self nextBytes:4.
- ^ ((((((res at:1) bitAnd:16r3F) * 256) + (res at:2)) * 256) + (res at:3)) * 256 + (res at:4)
-
-
-
- "
- |r|
- r := RandomGenerator new.
- Transcript showCR:r nextInteger.
- Transcript showCR:r nextInteger.
- Transcript showCR:r nextInteger.
- Transcript showCR:r nextInteger.
- "
-
- "Modified: / 11.11.1999 / 10:08:10 / stefan"
! !
!RandomGenerator methodsFor:'reading'!
@@ -309,6 +292,33 @@
"
!
+nextInteger
+ "return the next integral random number,
+ in the range 0 .. 16r3FFFFFFF."
+
+ |res|
+
+ RandFile == true ifTrue:[
+ ^ OperatingSystem randomBytesInto:4.
+ ].
+
+ res := self nextBytes:4.
+ ^ ((((((res at:1) bitAnd:16r3F) * 256) + (res at:2)) * 256) + (res at:3)) * 256 + (res at:4)
+
+
+
+ "
+ |r|
+ r := RandomGenerator new.
+ Transcript showCR:r nextInteger.
+ Transcript showCR:r nextInteger.
+ Transcript showCR:r nextInteger.
+ Transcript showCR:r nextInteger.
+ "
+
+ "Modified: / 11.11.1999 / 10:08:10 / stefan"
+!
+
nextIntegerBetween:start and:stop
"return an integral random number between start and stop"
@@ -385,11 +395,11 @@
!RandomGenerator class methodsFor:'documentation'!
version
- ^ '$Header: /cvs/stx/stx/libbasic2/RandomGenerator.st,v 1.15 2014-10-01 15:32:50 cg Exp $'
+ ^ '$Header$'
!
version_CVS
- ^ '$Header: /cvs/stx/stx/libbasic2/RandomGenerator.st,v 1.15 2014-10-01 15:32:50 cg Exp $'
+ ^ '$Header$'
! !