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)?


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

(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 :)

Search Discussions

Discussion Posts


Follow ups

Related Discussions

Discussion Navigation
viewthread | post
posts ‹ prev | 2 of 3 | next ›
Discussion Overview
groupmodule-authors @
postedApr 26, '14 at 9:28p
activeApr 26, '14 at 10:28p

2 users in discussion

Paul Bennett: 2 posts Karen Etheridge: 1 post



site design / logo © 2021 Grokbase