in reply to Largest integer in 64-bit perl

Perl has three internal numeric types, which vary based on how Perl was compiled.

So, on a 32-bit system configured for 32-bit IV, the 64-bit NV lets you store larger integers in a float even though NV is meant to be used for fractional values. On a 64-bit system, the IV is always 64-bit so there's no advantage to using NVs to store integers.

You can check the details of how your perl was compiled using the Config module.

perl -E 'use Config; say $Config{ivsize}; say $Config{nvsize}'

FWIW, the only 32-bit system I still have access to has a perl compiled with 64-bit IV.

Replies are listed 'Best First'.
Re^2: Largest integer in 64-bit perl
by LanX (Saint) on May 16, 2025 at 19:29 UTC
    I'm wondering:

    What are the cases where Perl decides to use UV for a variable, i.e. negatives are ruled out?

    or is this only for internal use, like array indices?

    Update

    To answer my own question, bitwise operations won't like a sign. (Doh!)

    FWIW: perlnumber only mentions this indirectly, for the exception made with use integer

    Cheers Rolf
    (addicted to the Perl Programming Language :)
    see Wikisyntax for the Monastery