Find the answer to your Linux question:
Results 1 to 3 of 3
Hello users, my problem is this: Code: #!/usr/bin/env perl use strict; use warnings; my $number1 = 50000000000000000000000; my $number2 = 50000000000000000000001; if ($number1 == $number2) { print "Nummern sind identisch\n"; ...
  1. #1
    Just Joined!
    Join Date
    Aug 2007
    Posts
    28

    [SOLVED] perl numeric variable "overflow" problem

    Hello users, my problem is this:

    Code:
    #!/usr/bin/env perl
    
    use strict;
    use warnings;
    
    my $number1 = 50000000000000000000000;
    my $number2 = 50000000000000000000001;
    
    if ($number1 == $number2) {
      print "Nummern sind identisch\n";
    }
    else {
      print "Nummern sind nicht identisch\n";
    }
    and perl say: yes, this are the same numbers (above 19digits, btw. if perl switch to exponential).

    But this is not true. Is there any solution? The numbers couldn't be lesser!

    Thanks for any idea/solution.
    raphael

  2. #2
    Linux Engineer wje_lf's Avatar
    Join Date
    Sep 2007
    Location
    Mariposa
    Posts
    1,192
    You have not an overflow problem, but a precision problem. Go here. I've never actually used this, but in Perl that's where you should go.

    Hope this helps.
    --
    Bill

    Old age and treachery will overcome youth and skill.

  3. #3
    Just Joined!
    Join Date
    Aug 2007
    Posts
    28

    [solved]

    Yes, this is exactly what I need. Thank you!
    Raphael

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
...