Negative scalar variable comparision

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • raghavendrap
    New Member
    • Oct 2008
    • 19

    #1

    Negative scalar variable comparision

    Hello Friends,
    Code:
                If 
            $tmp = -524219359 ;
           $tmp1= -532676607;
    
                    if($tmp >0 && $tmp1>0){
                         print(Temporary values are greater than Zero);
                    else {
                        print(Temporary values are less than zero);
                    }
    May i know what is the result we can get & with some explanation?


    Thanks
    Raghavendra
    Last edited by numberwhun; Nov 1 '08, 01:36 PM. Reason: Please use code tags!
  • raghavendrap
    New Member
    • Oct 2008
    • 19

    #2
    Hello friends,
    I got doubt in doing signed hexadecimal comparision.
    Here $tmp & tmp1 are negative decimal values , when i convert that numbers as hexadecimal & comparing with the mentioned below i am getting wrong result.
    May i the ultimate solution for signed comparision in perl
    Code:
     $tmp  = 0xc0211082;
     $tmp1 = 0xc0000082;
    
    if($tmp >0 && $tmp1>0){
    print("Temporary values are greater than Zero");
    }else {
    print("Temporary values are less than zero");
    }
    Last edited by numberwhun; Nov 1 '08, 01:37 PM. Reason: Please use code tags!

    Comment

    • KevinADC
      Recognized Expert Specialist
      • Jan 2007
      • 4092

      #3
      Originally posted by raghavendrap
      Hello Friends,
      Code:
                  If 
              $tmp = -524219359 ;
             $tmp1= -532676607;
      
                      if($tmp >0 && $tmp1>0){
                           print(Temporary values are greater than Zero);
                      else {
                          print(Temporary values are less than zero);
                      }
      May i know what is the result we can get & with some explanation?


      Thanks
      Raghavendra
      Correct all syntax errors and retry your code. Its pretty much worthless to ask a question then post bad code, we have no way of knowing if you are getting an error from the bad code or if you are using good code and getting an unusual return value, or what? So please try and always post code that has no syntax errors.

      Comment

      • raghavendrap
        New Member
        • Oct 2008
        • 19

        #4
        Hello KevinADC,
        I am new to perl , i am learning now, please let me know where i did wrong in my code which i have posted? & it would be helpful for me if u guide me by giving answers to my questions,i am very thankfull for you & its very proud for me by learing perl under your guidance.

        Thanks
        Raghavendra

        Comment

        Working...