develooper Front page | perl.perl5.porters | Postings from July 2018

Re: regen/ reuse troubles

Thread Previous | Thread Next
July 13, 2018 14:42
Re: regen/ reuse troubles
Message ID:
On Thu, 5 Jul 2018, 12:12 bulk 88, <> wrote:

> 32 bit perl generates different numbers in the mph hash than 64 bit
> perl. I'll guess more "use integer" is needed somewhere in the code.

Actually no, more use integer doesn't fix this and causes other issues.

The problem is that while use integer disables conversion to floating
point, which we *want*, it also causes the return from _fnv() to be
*signed* which then causes the minimum perfect hash construction to produce
surprising results. A simple fix on little endian boxen is to change the
return of _fnv() to

return unpack "V", pack "l", $h;

Which in my testing causes the 32bit builds to produce the same output as
the 64bit builds.

I am traveling right now so it's a bit difficult to do more than write this
mail. If no-one beats me to it I will push the patch when I return.

Fwiw, it would be nice to have a "no float_conversion" instead of "use
integer" for situations like this where we want to avoid floating point
conversion but where we do NOT want signed/integer semantics. "use integer"
affects too much and easily results in surprise, such as how it changes
the behaviour of the % (Modulo operator), which for instance causes an
infinite loop in the seed selection logic due to signedness issues.



Thread Previous | Thread Next Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About