By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
438,710 Members | 1,887 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 438,710 IT Pros & Developers. It's quick & easy.

Negative scalar variable comparision

P: 19
Hello Friends,
Expand|Select|Wrap|Line Numbers
  1.             If 
  2.         $tmp = -524219359 ;
  3.        $tmp1= -532676607;
  4.  
  5.                 if($tmp >0 && $tmp1>0){
  6.                      print(Temporary values are greater than Zero);
  7.                 else {
  8.                     print(Temporary values are less than zero);
  9.                 }
  10.  
May i know what is the result we can get & with some explanation?


Thanks
Raghavendra
Nov 1 '08 #1
Share this Question
Share on Google+
3 Replies


P: 19
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
Expand|Select|Wrap|Line Numbers
  1.  $tmp  = 0xc0211082;
  2.  $tmp1 = 0xc0000082;
  3.  
  4. if($tmp >0 && $tmp1>0){
  5. print("Temporary values are greater than Zero");
  6. }else {
  7. print("Temporary values are less than zero");
  8. }
  9.  
Nov 1 '08 #2

KevinADC
Expert 2.5K+
P: 4,059
Hello Friends,
Expand|Select|Wrap|Line Numbers
  1.             If 
  2.         $tmp = -524219359 ;
  3.        $tmp1= -532676607;
  4.  
  5.                 if($tmp >0 && $tmp1>0){
  6.                      print(Temporary values are greater than Zero);
  7.                 else {
  8.                     print(Temporary values are less than zero);
  9.                 }
  10.  
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.
Nov 1 '08 #3

P: 19
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
Nov 3 '08 #4

Post your reply

Sign in to post your reply or Sign up for a free account.