-
PCF: MarZam 2 RNG for VB.net?
Norm posted the source code of the rng from George Marsaglia and Arif Zaman more than 3 years ago on the page "Computing for Counters".
I tried to use this code for VB.net but I couldn't get it to work. I declared Seed1 and Seed2 as Integer. But I get a error stating "index out of range exception" for
uni = u(i97) - u(j97)
in the first line of
Public Function RND() As Double
Does anybody know a solution?
-
Norm Wattenberger: Re: MarZam 2 RNG for VB.net?
Integer has a different meaning in VB.Net. You could try a different type. Although that's an odd error. Sure you got all the code copied correctly?
> Norm posted the source code of the rng from George
> Marsaglia and Arif Zaman more than 3 years ago on the
> page "Computing for Counters".
> I tried to use this code for VB.net but I couldn't get
> it to work. I declared Seed1 and Seed2 as Integer. But
> I get a error stating "index out of range
> exception" for
> uni = u(i97) - u(j97)
> in the first line of
> Public Function RND() As Double
> Does anybody know a solution?
-
PCF: Re: MarZam 2 RNG for VB.net?
Thanks for your help. I copied the code directly from your post. The only changes I made(though the error also occurs without the changes) is that I deleted "ivec, i5 and j5" because they are not used local variables.
I tried to declare Seed1 and Seed2 as Double or Long, I still get the Error. This VB version has an IntelliSense feature and when I move the cursor obove the i97 and j97 in the line
uni = u(i97) - u(j97)
it says that both variables are -1. ??
I'm also using Windows Form Application and not the Console.
-
Norm Wattenberger: Re: MarZam 2 RNG for VB.net?
Well, that would happen if you called the rand routine before calling the init routine.
> Thanks for your help. I copied the code directly from
> your post. The only changes I made(though the error
> also occurs without the changes) is that I deleted
> "ivec, i5 and j5" because they are not used
> local variables.
> I tried to declare Seed1 and Seed2 as Double or Long,
> I still get the Error. This VB version has an
> IntelliSense feature and when I move the cursor obove
> the i97 and j97 in the line
> uni = u(i97) - u(j97)
> it says that both variables are -1. ??
> I'm also using Windows Form Application and not the
> Console.
-
PCF: It works now. Thank you Norm! :-) *NM*
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
Bookmarks