On Sat, Apr 26, 2014 at 05:27:58PM -0400, Paul Bennett wrote:
> Based on the results below, which show failures only on all linux-ld perls,
> and only failures on any linux-ld perl, what would you all recommend as my
> next debugging step(s)?
> 
> http://matrix.cpantesters.org/?dist=Path-Hilbert%201.001
> 
> I could make more tests, and do more-verbose testing, but if the math isn't
> working (specifically 2 ** 7 != 128, or at least log(128) / log(2) != 7),
> I'm not entirely sure where I'd even start looking.

The line that is causing issues is:

    2 ** int(log($n) / log(2)) == $n or confess("Side-length $n is not a power 
of 2");

I'd want to see what the value of that expression is, if it doesn't equal
$n. This could be due to bad rounding in int(log($n) / log(2)).

So that either means finding a machine with the right architecture to test
on, or put out a new release with a more specific error message.
At the same time, you can get the answer to your next question in advance:
print out the result of log($n) / log(2) before you convert it to an
integer.

(Also, your error message doesn't accurately portray the problem - you're
not just checking that the expression is a power of 2 -- which it has to
be, since the last thing you do is raise 2 to the nth power), but that it
equals a specific value.)

FWIW, you can check if a number is a power of 2 much more easily, by
leveraging the fact that binary is a base 2 system:

    ($n & ($n - 1)) == 0 or confess("Side-length $n is not a power of 2");

*much* faster than doing floating point operations :)

Reply via email to