Dear Perl experts,

The following subroutine contains a while loop that continues to
multiply $p by 2, until some condition is met.
(It's for computing a Collatz tree)
$p turns 0 in this loop, however, and it remains zero for ever, of course.

My question is, what is exactly its maximum value? As I have been browsing
the web for a while, but am unable to find this information for Perl data
types. (I know I could perhaps use BigIntegers, but don't know whether
that would be really necessary).

Is there a difference between 'long' and 'int' or something in Perl???

Thanks in advance.

sub left_child_of($) {
  my $p = shift;
  print "Left of $p\n";
  die("3 |/| p-1 (p = $p)") if ($p-1) % 3 != 0;
  $p = ($p-1) / 3;
  print "L$p\n";
  # keep multiplying by 2, until 3|p-1 and 2 |/| p-1
  while((($p-1) % 3 != 0) || (($p-1) % 2 == 0)) {
    print "L$p: 3 |/| p-1\n" if ($p-1) % 3 != 0;
    print "L$p: 2 | p-1\n" if ($p-1) % 2 == 0;
    $p <<= 1;
  }
  return $p;
}




-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>


Reply via email to