Go4Expert

Go4Expert (http://www.go4expert.com/)
-   Perl (http://www.go4expert.com/articles/perl-tutorials/)
-   -   Simple Negative Number Checking Subroutine in Perl (http://www.go4expert.com/articles/simple-negative-checking-subroutine-perl-t1756/)

pradeep 30Oct2006 17:57

Simple Negative Number Checking Subroutine in Perl
 
Many times we need to check whether a number is negative or not, here is a very simple subroutine to do that.

Code: Perl

sub isNegative
 {
     my($checkValue) = @_;
     if(abs($checkValue) != $checkValue)
     {
         # the value is negative
         return 1;
     }
     else
     {
         # number is positive
         return 0;
     }
 }



All times are GMT +5.5. The time now is 22:21.