Javascript random is nice, because it is between 0 and 1; So you can like:
Math.random()*sum where you get then numbers between 0 and the sum
like if sum is 7 it give's random's 0-7. And if you want transfer it out of zero you just add numbers to it.
So it good and easy, but Random in C gives BIG numbers it harder to use, here how you alter it similar to JS-random:
Then use like JS
But you must, before use that JSrandom, make that time seeds thingy, as usually, that make random more random
How it works? Lowest number that C random gives is 32767 that what they promise. If you then use it to "%(modulo)" random it ensure that all numbers are lower than it(32767) or equal. When it(the calculation) be then divided by 32767 it make so that what was before 32767 is now 1 and all other numbers be between 0 to 1.
No comments:
Post a Comment