• Create Account

Need scary sound effects or creepy audio loops for your next horror-themed game? Check out Highscore Vol.3 - The Horror Edition in our marketplace. 50 sounds and 10 loops for only \$9.99!

### #ActualExpert Novice

Posted 28 April 2012 - 07:32 PM

Okay I'm getting along with my RNG! It's kind of bloated so I'm shaving it down.
I know some of this stuff might be overkill but I'm going to be generating a fair amount of random numbers.
Besides, I'm only really doing this to learn and have fun. But I am using it in my work later on, if it's any good lol.

I want my RNG to be nearly as fast as a congruential generator like:
{ R = ((aR + b) mod c) }.
It doesn't have to be as lightweight or as good, of course.

1) How fast, relatively is addition and subtraction compared to and/or/xor?
How fast, relatively is multiplication, division, modulus compared to addition and subtraction?

1.5) Could someone ball park a number of bit operations that would be acceptable to meet my goals for speed?
I'm building the RNG entirely out of and, or, xor, not, <<, >>... so I need to know a good maximum number of these I'm allowed to have.

2) Are two bitshifts as fast as one of equal size?
Like is { a << 5 } faster than { a << 2; a << 3; } or is it done one at a time and thus equally fast?

Thoughts?

### #1Expert Novice

Posted 28 April 2012 - 05:51 PM

Okay I'm getting along with my RNG! It's kind of bloated so I'm shaving it down. I have a question though.

I want mine to be about as fast, if not a bit faster than
{ a * b mod c + d mod e }.

1) So could someone ball park a number of bit operations that would be acceptable to meet my goals?
I'm building one entirely out of and, or, xor, not, <<, >>, etc.

2) Might use + and - as well but I'm not sure those are terribly fast.

3) If I do { 0x11111111 << 2 } I get { 0x11111100 } right? So to rotate should I spill into another byte and then "or" them?

Thoughts?

PARTNERS