in reply to Integer overflow in -s or file stat results

perl -V:sizesize -V:sizetype

On my Win32 perl 5.24.0 x64, I get 8byte size_t. On my ancient CentOS 4.6 perl 5.8.5 (got you beat with how ancient a perl I'm stuck with is), I see 4byte size_t. If you convert your 4byte negative into a 4byte unsigned, or into a float using float(4byte signed integer) + 2**32, you'll get your 3.8GB size:

perl -e 'printf "%08x => %.0f => %.3e\n", $_, $_+2**32, $_+2**32 for -426648576'

I am thus betting you'll get -V:sizesize of 4 bytes, (edit:) but it will be a float rather than an int

edit2: improve parens in the paragraph. Also, to base the conversion on the sizesize, use Config; $Config{sizesize}==4 ? convert($filesize): $filesize...

edit3: clarify signed integer as the argument to float(); remove extra single-quote in edit2. Why didn't I see these before posting?

Replies are listed 'Best First'.
Re^2: Integer overflow in -s or file stat results
by Laurent_R (Canon) on Mar 07, 2017 at 18:02 UTC
    Thank you very much, pryrt for these ideas.

    Unfortunately,

    perl -V:sizesize -V:sizetype
    does not produce anything useful under VMS (just the same output as Perl -V)

    Converting the negative output would work for the specific example I gave, but I am afraid it is probably not a reliable option because some other files are still significantly larger (10 GB, or so), so there is no way for me to know how many times I would need to add 2**32.

    Thanks anyway for your answer.