Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot
 
PerlMonks  

how do i test a number negative or positive?

by dswimboy (Initiate)
on Apr 09, 2002 at 21:33 UTC ( #157866=perlquestion: print w/replies, xml ) Need Help??

dswimboy has asked for the wisdom of the Perl Monks concerning the following question:

This node falls below the community's threshold of quality. You may see it by logging in.

Replies are listed 'Best First'.
Re: how do i test a number negative or positive?
by Kanji (Parson) on Apr 09, 2002 at 22:25 UTC
Re: how do i test a number negative or positive?
by PodMaster (Abbot) on Apr 10, 2002 at 03:19 UTC
    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'"; }
Re: how do i test a number negative or positive?
by dswimboy (Initiate) on Apr 09, 2002 at 21:43 UTC
    wow...i'm sorry. how do you test if a number is even or odd...i'm sorry

    Originally posted as a Categorized Answer.

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others perusing the Monastery: (1)
As of 2022-08-08 04:55 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?