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

Long Integer

P: 34
Hi All,
I have the following code,
Expand|Select|Wrap|Line Numbers
  1. $min=12345678901234567890;
  2. $max=12345678901234567899;
  3. print "max=$max, min=$min \n";
  4. if ($min < $max)
  5. {
  6.     print "Output : ok \n";
  7. }
  8. else
  9. {
  10.     print "Output : not ok \n";
  11. }
  12.  
Output:
max=1.23456789012346e+19, min=1.23456789012346e+19
Output : not ok

Why The output is in floating point. How can I solve this Issue.
Apr 15 '08 #1
Share this Question
Share on Google+
3 Replies


eWish
Expert 100+
P: 971
What are you expecting the results to be?

--Kevin
Apr 15 '08 #2

P: 34
Hi All,
I have the following code,
Expand|Select|Wrap|Line Numbers
  1. $min=12345678901234567890;
  2. $max=12345678901234567899;
  3. print "max=$max, min=$min \n";
  4. if ($min < $max)
  5. {
  6.     print "Output : ok \n";
  7. }
  8. else
  9. {
  10.     print "Output : not ok \n";
  11. }
  12.  
Output:
max=1.23456789012346e+19, min=1.23456789012346e+19
Output : not ok

Why The output is in floating point. How can I solve this Issue.
Hi,

when I try to compare the values I am getting the wrong results. The difference between $max and $min is "0"

Regards
Pnsree
Apr 16 '08 #3

eWish
Expert 100+
P: 971
You are only comparing to see if it is less than, do a check to see if is is equal, less than or greater than.

Expand|Select|Wrap|Line Numbers
  1. my $min = 12345678901234567890;
  2. my $max = 12345678901234567899;
  3.  
  4.    print "max=$max, min=$min \n";
  5.        if ($min == $max) {
  6.         print "Output : Equal \n";
  7.     } elsif ($min < $max) {
  8.         print "Output : Less Than \n";
  9.     } elsif ($min > $max) {
  10.         print "Output: Greater Than\n";
  11.     } else {
  12.         print "Output not equal, not less than not greater than\n";
  13.     }
--Kevin
Apr 16 '08 #4

Post your reply

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