superbigio
12-18-2002, 03:40 PM
Hi,
I am working on a program where speed is crucial.
I need a fast random generator algorithm and I decided to use the one on page 284 of NR ("An even quicker generator");
idum = 1664525L*idum + 1013904223L;
On the following page there's a nice trick to make the generator output floating point numbers in the range from 0 to 1 avoiding the division.
It just so happen that I need a range from -1 to 1.
I was wondering:
- if it's possible to do that by just manipulating the bits again (without having to multiply or divide).
- how should I modify the code to do that.
Thanks for helping...
Luigi Castelli:confused:
I am working on a program where speed is crucial.
I need a fast random generator algorithm and I decided to use the one on page 284 of NR ("An even quicker generator");
idum = 1664525L*idum + 1013904223L;
On the following page there's a nice trick to make the generator output floating point numbers in the range from 0 to 1 avoiding the division.
It just so happen that I need a range from -1 to 1.
I was wondering:
- if it's possible to do that by just manipulating the bits again (without having to multiply or divide).
- how should I modify the code to do that.
Thanks for helping...
Luigi Castelli:confused: