Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?
 
PerlMonks  

Re: how do i test a number negative or positive?

by PodMaster (Abbot)
on Apr 10, 2002 at 03:19 UTC ( [id://157945]=note: print w/replies, xml ) Need Help??


in reply to how do i test a number negative or positive?

check out perlsyn and perlop (in particular the comparison operators)
my $num = $_ = 4; if($num >= 0) { die "$num is positive"; } else { die "$num is negative (but we already knew that)"; } # or even ;) my $num = $_ = -4; if(substr($num,0,1,) eq '-') { die "I, $num, feel so negative today"; } else { die "$num says 'Things are looking up'"; }

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://157945]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others musing on the Monastery: (2)
As of 2024-04-24 16:32 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found