squiblo Posted October 21, 2009 Share Posted October 21, 2009 just a general question guys a girls, is the rand() function 100% random or is it based on time? Quote Link to comment https://forums.phpfreaks.com/topic/178533-rand-function/ Share on other sites More sharing options...
Alex Posted October 21, 2009 Share Posted October 21, 2009 This comes up quite often.. For any practical use it's random enough, but it's still generated by some mathematical procedure. Quote Link to comment https://forums.phpfreaks.com/topic/178533-rand-function/#findComment-941565 Share on other sites More sharing options...
Mark Baker Posted October 21, 2009 Share Posted October 21, 2009 mt_rand() is fractionally faster though Quote Link to comment https://forums.phpfreaks.com/topic/178533-rand-function/#findComment-941567 Share on other sites More sharing options...
squiblo Posted October 21, 2009 Author Share Posted October 21, 2009 how is mt_rand() different from rand()? Quote Link to comment https://forums.phpfreaks.com/topic/178533-rand-function/#findComment-941571 Share on other sites More sharing options...
Mark Baker Posted October 22, 2009 Share Posted October 22, 2009 how is mt_rand() different from rand()?it's faster Quote Link to comment https://forums.phpfreaks.com/topic/178533-rand-function/#findComment-941757 Share on other sites More sharing options...
Daniel0 Posted October 22, 2009 Share Posted October 22, 2009 just a general question guys a girls, is the rand() function 100% random or is it based on time? No, it's not possible to generate 100% random numbers using a computer because it's what you call a deterministic device. A computer can't pick a random number off the top of its "head" like a human can. A computer can generate what you call a pseudo-random number, and a program/function/algorithm that does this is called a PRNG (pseudo-random number generator). These rely on some mathematical tricks and a seed value. Giving it the same seed will result in the same pseudo-random number. The seed is often based on the computer's internal clock. Quote Link to comment https://forums.phpfreaks.com/topic/178533-rand-function/#findComment-941864 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.