title: C: f>0 vs Perl: $f>0?
body: <p>This C code displays Fibonacci numbers:</p>
  
  <pre><code>#include &lt;stdio.h&gt;
  int main(){
     for (long long int t, i=1, p=1, f=2; f&gt;0 ; i++, t=f, f+=p, p=t)
        printf("%lli: %lli\n", i, f); 
     }
  </code></pre>
  
  <p>As intended it stops without having to hard code the number of iterations.</p>
  
  <p>The code in Perl is attempting to use the same technique:</p>
  
  <pre><code>my $t;
  my $p=1;
  my $f=2;
  for ($i=1; $f&gt;0; $t=$f, $f+=$p, $p=$t, $i++){
     printf("%i: %i\n", $i, $f);
     if ($i&gt;50){exit;}
     }
  </code></pre>
  
  <p>But it does not stop as expected, at the point the value overflows at 45 rather than at
  51 when the extra check kicks in.</p>
  
  <pre><code>44: 1836311903
  45: -1323752223
  46: -1
  47: -1
  48: -1
  49: -1
  50: -1
  51: -1
  </code></pre>
  
  <p>What does Perl do differently that causes this?</p>