Gossamer Forum
Home : Products : Links 2.0 : Customization :

Real simple question about math functions

Quote Reply
Real simple question about math functions
Hello all!

Yes its me again! Smile

What funtion in Perl determines if a variable is divisible by a specified interger?
Example: I need blue!
if ($i is divisible by 2 == 0) {
$x = 1;}
else { $x = 0; }


-or-

What funtion gets the remander from division. I could be mistaken, but as I recall from when I studied C ++ a hundred years ago that the "%" was used. 5%2=1 4%2=0

Example: I need green!
if ($i % 2 == 0) {
$x = 1;}
else { $x = 0; }


Thanks,

beetleman
beetlemanTongue

Marcus L. Griswold
Quote Reply
Re: [beetleman] Real simple question about math functions In reply to
Nevermind, found a way around my delima,

Thanks anyway,

beetleman
beetlemanTongue

Marcus L. Griswold
Quote Reply
Re: [beetleman] Real simple question about math functions In reply to
It would have been:

if (($i / 2) == 0) {


Last edited by:

RedRum: Nov 5, 2001, 4:08 AM
Quote Reply
Re: [RedRum] Real simple question about math functions In reply to
how about...

Code:
($i%2) ? ($color='white') : ($color='grey')

Paul, what you posted won't work. when have you ever had a case where you divided anything by 2 and got 0, except 0/2??

--Philip
Links 2.0 moderator
Quote Reply
Re: [PerlFreak] Real simple question about math functions In reply to
I mis-sread the post. I thought it was asking how you divide something in perl