Browse Source

Improved range of Rand(). Resolves #246.

Brucey 2 years ago
parent
commit
80e9f46edb
1 changed files with 6 additions and 4 deletions
  1. 6 4
      random.mod/random.bmx

+ 6 - 4
random.mod/random.bmx

@@ -6,12 +6,14 @@ bbdoc: Random numbers - Default implementation
 End Rem
 Module BRL.Random
 
-ModuleInfo "Version: 1.10"
+ModuleInfo "Version: 1.11"
 ModuleInfo "Author: Mark Sibly, Floyd"
 ModuleInfo "License: zlib/libpng"
 ModuleInfo "Copyright: Blitz Research Ltd"
 ModuleInfo "Modserver: BRL"
 
+ModuleInfo "History: 1.11"
+ModuleInfo "History: Improved range of Rand()"
 ModuleInfo "History: 1.10"
 ModuleInfo "History: Added GetName()."
 ModuleInfo "History: 1.09"
@@ -117,9 +119,9 @@ Type TRandomDefault Extends TRandom
 	]
 	End Rem
 	Method Rand:Int(minValue:Int, maxValue:Int = 1)
-		Local Range:Int=maxValue-minValue
-		If Range>0 Return Int( RndDouble()*(1+Range) )+minValue
-		Return Int( RndDouble()*(1-Range) )+maxValue
+		Local Range:Long=Long(maxValue)-minValue
+		If Range>0 Return Long( RndDouble()*(1+Range) )+minValue
+		Return Long( RndDouble()*(1-Range) )+maxValue
 	End Method
 	
 	Rem