Long Integer

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • pnsreee
    New Member
    • Apr 2007
    • 34

    Long Integer

    Hi All,
    I have the following code,
    [code=perl]
    $min=1234567890 1234567890;
    $max=1234567890 1234567899;
    print "max=$max, min=$min \n";
    if ($min < $max)
    {
    print "Output : ok \n";
    }
    else
    {
    print "Output : not ok \n";
    }
    [/code]
    Output:
    max=1.234567890 12346e+19, min=1.234567890 12346e+19
    Output : not ok

    Why The output is in floating point. How can I solve this Issue.
    Last edited by eWish; Apr 15 '08, 03:06 PM. Reason: Please use code tags
  • eWish
    Recognized Expert Contributor
    • Jul 2007
    • 973

    #2
    What are you expecting the results to be?

    --Kevin

    Comment

    • pnsreee
      New Member
      • Apr 2007
      • 34

      #3
      Originally posted by pnsreee
      Hi All,
      I have the following code,
      [code=perl]
      $min=1234567890 1234567890;
      $max=1234567890 1234567899;
      print "max=$max, min=$min \n";
      if ($min < $max)
      {
      print "Output : ok \n";
      }
      else
      {
      print "Output : not ok \n";
      }
      [/code]
      Output:
      max=1.234567890 12346e+19, min=1.234567890 12346e+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

      Comment

      • eWish
        Recognized Expert Contributor
        • Jul 2007
        • 973

        #4
        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.

        [CODE=perl]my $min = 123456789012345 67890;
        my $max = 123456789012345 67899;

        print "max=$max, min=$min \n";
        if ($min == $max) {
        print "Output : Equal \n";
        } elsif ($min < $max) {
        print "Output : Less Than \n";
        } elsif ($min > $max) {
        print "Output: Greater Than\n";
        } else {
        print "Output not equal, not less than not greater than\n";
        }[/CODE]

        --Kevin

        Comment

        Working...