jeudi 4 juin 2015

Exception (integer overflow) when initializing 64-bit Mersenne Twister

I am using the 64-bit verison of the Mersenne Twister, specifically the version:

 A C-program for MT19937-64 (2004/9/29 version).
 Coded by Takuji Nishimura and Makoto Matsumoto.

and am receiving an integer overflow when compiling into the Release but don't get the exception during run-time in Debug. I have integer overflow turned OFF in the Advanced Compile options.

The exception is being thrown on the mt(mti) = .... line inside the loop.

Strangely, I am getting this exception now every run-time in Debug compile, so did something creep into the Intel i7 floating point registers, such that I need to power down and then power up to wipe memory?

Lastly, why does initialization in Release throw the exception all the time, but not initializing in Debug?

' The array for the state vector 
Friend Shared mt(DefineConstants.NN - 1) As ULong
' mti==NN+1 means mt[NN] is not initialized 
Friend Shared mti As Integer = DefineConstants.NN+1

' initializes mt[NN] with a seed 
Public Shared Sub init_genrand64(ByVal seed As ULong)
    mt(0) = seed
    For mti = 1 To DefineConstants.NN - 1
        mt(mti) = (6364136223846793005UL * (mt(mti - 1) Xor (mt(mti - 1) >> 62)) + mti)
    Next mti
End Sub




Aucun commentaire:

Enregistrer un commentaire