467,882 Members | 1,199 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 467,882 developers. It's quick & easy.

Negative scalar variable comparision

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
  • viewed: 1786
Share:
3 Replies
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 2GB
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
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.

Similar topics

2 posts views Thread by Tom | last post: by
1 post views Thread by G Fernandes | last post: by
3 posts views Thread by Ken Adeniji | last post: by
5 posts views Thread by Eli | last post: by
2 posts views Thread by Oded Dror | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.