This maybe a dumb question but I been googling and looking for an answer. How can I create a 16 BIT random number?

All 16 bits are random. Like I can do . Can I do this ? int16_t bitNum = rand()%100; //bitNum in the range of 0 to 99. ?

yes this will work: int16_t bitNum = (int16_t)rand()%0x10000; //bitNum in the range of 0 to 0xffff Note that rand() is not considered random enough for applications where a truly random number is required. Also, the use of %0x10000 causes the number to not be perfectly uniformly distributed. None the less, for most applications it will probably be good enough. Also, you may want to look into srand if you want to initiaze your random number generator with a random seed first (otherwise your code will produce the same sequence of random numbers every time it runs, which you may or may not care about.

Would you mind explaining that further? Layman's terms a bonus. Not a software person, but not a stranger to math either; the above made me curious.

a 16 bit number can range from 0 to 65535. If you apply %100 to get a value from 0-100 then you will have 655 sets of numbers that go from 0 to 100 and 1 set that goes from 0 to 35. So the numbers 0 to 35 will appear with slightly more frequency. It is "fairly" random but not truly random. There are also problems in generating random numbers because the generation relies on techniques that are not random and can possibly be predicted. Many encryption exploits have been done based on this. Some programs when generating a random number will have you wiggle a mouse in a box and use that as input to their RNG.

rand() is a pseudo-random number generator. In math terms, it is deterministic. You can "predict" its outputs based on its inputs. Ideally, for something to be truly random, you want something leaning towards non-deterministic. What constitutes as a "good" random number generator is still of great debate today. Basically, digital computers are imperfect (or is that too perfect? hmm) for generating random numbers. Still, there are some really good RNG engines out there, such as those used by the C++ library I mentioned above. There are even some RNG engines that get assistance from the underlying hardware for introducing even more "randomness" into the result. Most of these hardware implementations rely on "noise" that is inherent of the analog signals found in the power delivery of the underlying circuits. This "noise" is often referred to as "entropy", which is just a fancy word for chaos. The more chaos in a system, the more potential for harvesting randomness. Unless you need NSA level encryption robustness, most of these standard library implementations are good enough for most projects. Coming up with one's own random number generator isn't that hard. You could literally use twitter as a source for a random seed. There's more random shit on the internet these days than any super AI could ever predict.

I'm assuming you are specifically asking about rand() and not why %100 makes it non uniform. I don't know too much about this subject, but here are some links that might give you more info: https://channel9.msdn.com/Events/GoingNative/2013/rand-Considered-Harmful https://wiki.sei.cmu.edu/confluence...+function+for+generating+pseudorandom+numbers

Would never have thought of that.. Thanks to everyone for replying as well, i like learning new things Expected this to be complicated, but more like the other way round; like conceiving the way for a simple program to "pick" a trully "random" moment, but never thought of the pool itself.