473,506 Members | 14,630 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

RAND_MAX

According to php.net, mt_rand() and rand()'s$max value is, by default,
RAND_MAX. This suggests to me that RAND_MAX is a constant, however,
the following PHP script shows this not to be the case:

<?php
echo defined('RAND_MAX') ? 'defined' : 'not defined';
?>

Any ideas as to why this is?

Jun 24 '07 #1
2 4601
..oO(yawnmoth)
>According to php.net, mt_rand() and rand()'s$max value is, by default,
RAND_MAX. This suggests to me that RAND_MAX is a constant, however,
the following PHP script shows this not to be the case:

<?php
echo defined('RAND_MAX') ? 'defined' : 'not defined';
?>

Any ideas as to why this is?
Just because something is written in caps in the manual doesn't
necessarily mean that it's a PHP constant. It could also be a system-
dependent constant in the C source code.

Micha
Jun 24 '07 #2
yawnmoth wrote:
According to php.net, mt_rand() and rand()'s$max value is, by default,
RAND_MAX. This suggests to me that RAND_MAX is a constant, however,
the following PHP script shows this not to be the case:

<?php
echo defined('RAND_MAX') ? 'defined' : 'not defined';
?>

Any ideas as to why this is?
RAND_MAX is not a php constant, it's defined in the standard C library
and is platform dependent. For example, on windows it's only 32767.

--
gosha bine

extended php parser ~ http://code.google.com/p/pihipi
blok ~ http://www.tagarga.com/blok
Jun 24 '07 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

41
3015
by: AngleWyrm | last post by:
I have created a new container class, called the hat. It provides random selection of user objects, both with and without replacement, with non-uniform probabilities. Uniform probabilities are a...
9
10537
by: Martin | last post by:
I am trying to write code that selects a random number in the range 0 to n, where n can be substantially greater than the RAND_MAX on my system which is 32767. I am using VC++ 2003 FWIW. As you...
6
1497
by: pembed2003 | last post by:
Hi All, I hope I am posting a C question instead of a C++ this time. I have the following program: #include<stdlib.h> #include<stdio.h> #include<math.h> #include<time.h> int main(int...
8
4372
by: Jack | last post by:
When I use rand(), is the RAND_MAX value how long I am guaranteed that the same value will not appear twice? And is this a floating window? For example, if RAND_MAX is 32767, and I make...
12
12245
by: 海风 | last post by:
How to generate a random integer that is bigger than RAND_MAX. the RAND_MAX is the max of rand function. and equal to 0x7fff
0
7105
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7371
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
7023
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
7479
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
4702
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3188
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3178
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1534
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
757
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.