Ticket #90 (innreport mishandles leap years)

Julien ÉLIE julien at trigofacile.com
Sun Jan 11 08:58:59 UTC 2009


Hi Alexander,

I have an issue when I run innreport with the patch (even on a normal
news.notice file):

    Illegal division by zero at ./innreport line 1697.

  foreach $key (sort keys %$dates) {
    $x_min = $key if $x_min > $key;
    $x_max = $$dates{$key} if $x_max < $$dates{$key};
--> my $t = $$out{$key} / ($$dates{$key} - $key);
    $y_max_out = $t if $y_max_out < $t;
    $t = $$in{$key} / ($$dates{$key} - $key);
    $y_max_in = $t if $y_max_in < $t;
  }


>> Dec 31 19:27:55 news innd: ME status seconds 147396 accepted 3217 refused 11238 rejected 12 duplicate 0 accepted size 3885778 
>> duplicate size 0 rejected size 21506
>> Jan  9 19:27:58 news innd: news.matabio.net status seconds 23306 accepted 1 refused 1350 rejected 0 duplicate 0 accepted size 
>> 2018 duplicate size 0 rejected size 0
>
> The following patch contains fixes the third (least interesting) problem so that
> your test cases works again.

Thanks.  It now gives a report for:
    Jan  9 19:27:58 -- Jan  9 19:27:58

If I put a third date:
    Dec 31 19:27:55
    Dec 31 19:27:57
    Jan  9 19:27:58
it gives a report for:
    Dec 31 19:27:57 -- Jan  9 19:27:58

But I think it is the second problem (descending sort), if I understand well
your comments.



> +# 1E30 is a very large number: Digit '1' followed by thirty zeroes.
> +# With binary radix the number has 100 digits.
> +# On contemporary hardware Perl converts it to the maximum value of
> +# an unsigned integer (either 32 or 64 bit).

    http://www.perlmonks.org/?node_id=718414

If Perl is compiled with 64-bit ints and quadruple floats, the max is
2^113.  Perl changes its format to store big values.  Interesting behaviour.

Nonetheless, we will normally not reach such high values with innreport.


> +  # Assume that every month has 36 days: 36 * 24 / 3 = 288
> +  # If dates differ for more than 300 days they are assumed to be in
> +  # different years. However, this limit of 300 is based on a year of
> +  # 12 * 36 = 432 days. Mapped to a year of 365 days the limit is
> +  # 300 / 432 * 365 = 253.310 days

Amusing!

-- 
Julien ÉLIE

« Je ne suis ni pour ni contre, bien au contraire ! » (Coluche) 




More information about the inn-workers mailing list