- Original Message -
From: "joel boonstra" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Friday, January 16, 2004 4:54 PM
Subject: Re: [PHP] odd and even numbers
> Jake,
>
> > This worked.. somewhat.. here is what I want to do though.
> >
- Original Message -
From: "Katie Dewees" <[EMAIL PROTECTED]>
To: "Jake McHenry" <[EMAIL PROTECTED]>
Sent: Friday, January 16, 2004 4:44 PM
Subject: RE: [PHP] odd and even numbers
> Can you just set a value somewhere (in a flat file, or a database)
Jake,
> This worked.. somewhat.. here is what I want to do though.
>
> I have two people checking the same email address. I want to break up the
> emails 50/50 to each person. What values can I put into the random number
> generator so that I can get closer to 50/50. I just set up a test page wit
- Original Message -
From: "joel boonstra" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Friday, January 16, 2004 3:35 PM
Subject: Re: [PHP] odd and even numbers
> On Fri, Jan 16, 2004 at 02:30:59PM -0600, Jeremy wrote:
> > function isOdd ($value) {
&g
On Fri, 2004-01-16 at 15:17, Jake McHenry wrote:
> I have a random number being generated from 1 to 501, is there an easy way for me to
> tell if the result is an odd or even number?
(1 & number) ? odd : even;
E.g.
';
while($i < 10) {
(1 & $i) ? print($i . ' is odd') : print($i . ' is
- Original Message -
From: "joel boonstra" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Friday, January 16, 2004 3:35 PM
Subject: Re: [PHP] odd and even numbers
> On Fri, Jan 16, 2004 at 02:30:59PM -0600, Jeremy wrote:
> > function isOdd ($value) {
&g
On Fri, Jan 16, 2004 at 02:30:59PM -0600, Jeremy wrote:
> function isOdd ($value) {
> return (int)$value % 2 ? true : false;
> }
>
> Returns true/false if the value is odd. Also rounds down floating point numbers
> given as the test value.
No need to explicitly state "true" and "false". J
:18 PM
To: [EMAIL PROTECTED]
Subject: [PHP] odd and even numbers
I have a random number being generated from 1 to 501, is there an easy way for me to
tell if the result is an odd or even number?
Thanks,
Jake
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http
On Fri, 2004-01-16 at 13:17, Jake McHenry wrote:
> I have a random number being generated from 1 to 501, is there an easy way for me to
> tell if the result is an odd or even number?
Yep. The modulus operator (%). Your number mod 2 will be 1 if it is odd
and 0 if it is even.
http://us4.php.net/m
I have a random number being generated from 1 to 501, is there an easy way for me to
tell if the result is an odd or even number?
Thanks,
Jake
10 matches
Mail list logo