c# - Split random integer into 4 random bytes -


can split random unsigned integer 4 random unsigned bytes values (0-255) uniformly distributed? if so, how?

i tried in c# seems 0 used more other numbers.

byte[] bytes = bitconverter.getbytes(u); 

which seems doing this:

byte[] array = new byte[4]; fixed (byte* ptr = array) {     *(int*)ptr = value; } return array; 

here of random integers: http://pastebin.com/sdwbqkjk

if u consists of random bits only, including significant bit or byte, code work as-is. on clr uint has 4 bytes, each of 8 bits long. work.

it doesn't work source of random numbers faulty. print 100 of them in hex format (tostring("x8")) console. see there lot more zeroes should be.

fix source of random numbers.


Comments

Popular posts from this blog

commonjs - How to write a typescript definition file for a node module that exports a function? -

openid - Okta: Failed to get authorization code through API call -

thorough guide for profiling racket code -