I'm trying to create a long (= 2^31) list of 32 and 16 bit random numbers. For 32 bits, I'm using lfsr113_Bits() from implementation of rand() , but I'm not sure what would be the best way to get a quality sequence of 16 bit numbers.
Unfortunately, the included in rand() is a bit short since as per documentation: "The rand function returns a pseudorandom integer in the range 0 to RAND_MAX (32767).
I'm thinking about using the lfsr113_Bits() and a union to get 16 bit numbers by utilizing:
union {
uint16 i16[2];
uint32 i32;
} u;
u.i32 = lfsr113_Bits();
And then use the number from either u.i16[0] or u.i16[1], or perhaps from both, one after another, but I have that gut feeling that the sequences obtained this way could be significantly worse than one obtained by using a native 16 bit generator.
Any idea on what would be the best approach to generate 16 bit random numbers?