1 Replies - 1664 Views - Last Post: 06 August 2010 - 08:25 AM

#1 girasquid   User is offline

  • Barbarbar
  • member icon

Reputation: 108
  • View blog
  • Posts: 1,825
  • Joined: 03-October 06

Simple Negative Number Check

Posted 03 October 2006 - 12:26 PM

Description: Pass the number you want checked into the subroutine, and it will return a 1 if the number is negative, and a 0 if it is positive.Checks whether a passed argument is negative or not.
sub checkNegative {
    my($checkValue) = @_;
    if(abs($checkValue) != $checkValue) {
        # in this case, the value is negative; return 1
        return 1;
    } else {
        # number is positive; return 0
        return 0;
    }
}


Is This A Good Question/Topic? 0
  • +

Replies To: Simple Negative Number Check

#2 haptiK   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 0
  • Joined: 06-August 10

Re: Simple Negative Number Check

Posted 06 August 2010 - 08:25 AM

if($val < 0) //moron
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1