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


in reply to Re^2: [XS] Weird behaviour on some Linux systems
in thread [XS] Weird behaviour on some Linux systems

But when you're trying to (mis)use formatting of doubles in the way that List::Util::uniqnum() does, then you really do need a width of 19 decimal digits if ivsize is also 8.

I certainly sympathize. I've been trying to solve the same problem in List::Util::PP, and so far have settled on using roughly pack('FJ', $_, $_). There are still some issues around the unsigned int upper boundary though.

It should be possible to avoid the special case to use Gconvert by tweaking the format you use. I can get the full width output on my Ubuntu system by using '%0.19g':

$ perl -e'printf "%.19g\n", 2 ** 57'
1.4411518807585587e+17
$ perl -e'printf "%0.19g\n", 2 ** 57'
144115188075855872

Replies are listed 'Best First'.
Re^4: [XS] Weird behaviour on some Linux systems
by syphilis (Bishop) on Oct 14, 2019 at 13:11 UTC
    I can get the full width output on my Ubuntu system by using '%0.19g'

    Good catch. That works with sv_setpvf() in XS, too.
    I'll incorporate it into https://github.com/Dual-Life/Scalar-List-Utils/pull/80 tomorrow.
    AFAIK that pull request does the job fine - but this observation of yours should enable me to reduce a bit of clutter in Makefile.PL and ListUtil.xs.

    Thanks !!

    Cheers,
    Rob