after getting the answer my problem might well become a stupid one
i am programming some c code and need to generate hundrets of random numbers. as i broused the web i consider the random() function best for osx (fast and nearly true random, isnt it?). surely ill randomiz the seed unsing srandom(time(NULL)) on startup.
Apple quotes random() will give me an uniformly distributed set of numbers inbetween -32767 and 32767. As far as good... but. On a bit-related point of view it doesnt make any sens to me. the total number of possible results is 2^16-1. A unusable amount. Its uneven; calculating a large amount of yes-or-no states [e.g. trueOrFalse = (short) (random()+32767)/31767; ] would differ by one every 65535th time). Not only that, i fear random() generates halve of a unsigned short (2^15) and randomly adds the sign. well, would it do so, there would be a +0 and a -0, means the distribution wouldnt be uniformly at all.
The longer i write the more i get suspicious. Maybe i messed it up while i randomized my brain. Maybe all whats unlogical to me is logical to others
sorry for beeing discursive once again... but thanks for ideas.
doc
i am programming some c code and need to generate hundrets of random numbers. as i broused the web i consider the random() function best for osx (fast and nearly true random, isnt it?). surely ill randomiz the seed unsing srandom(time(NULL)) on startup.
Apple quotes random() will give me an uniformly distributed set of numbers inbetween -32767 and 32767. As far as good... but. On a bit-related point of view it doesnt make any sens to me. the total number of possible results is 2^16-1. A unusable amount. Its uneven; calculating a large amount of yes-or-no states [e.g. trueOrFalse = (short) (random()+32767)/31767; ] would differ by one every 65535th time). Not only that, i fear random() generates halve of a unsigned short (2^15) and randomly adds the sign. well, would it do so, there would be a +0 and a -0, means the distribution wouldnt be uniformly at all.
The longer i write the more i get suspicious. Maybe i messed it up while i randomized my brain. Maybe all whats unlogical to me is logical to others
sorry for beeing discursive once again... but thanks for ideas.
doc