This is regarding the max value of rand();


#1

https://www.codecademy.com/en/courses/web-beginner-en-7I7Xm/0/5?curriculum_id=5124ef4c78d510dd89003eb8

The max value of rand(); is 32767. But when I type print rand(); i get a very high value , I have attached a screenshot for your reference. Why is teh value greater than 32767.


Replace this line with your code.
print rand();



#2

If called without the optional min, max arguments rand() returns a pseudo-random integer between 0 and getrandmax(). If you want a random number between 5 and 15 (inclusive), for example, use rand(5, 15).

Note: On some platforms (such as Windows), getrandmax() is only 32767. If you require a range larger than 32767, specifying min and max will allow you to create a range larger than this, or consider using mt_rand() instead.

check it here

echo (getrandmax()) // The largest possible value returned by rand()


#3

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.