Re: Strange behavior when printing a 4G+ integer on 32bits platform.

2018-11-15 Thread Tetsuo Handa
On 2018/11/15 9:27, sisyphus wrote: > Are you actually encountering files larger than 1e15 bytes ? On 32bit kernels, filesystems would not allow such large files. For example, max size for xfs filesystem is 16TB. Even on 64bit userspace, nobody will want to upload such large file via network. >

Re: Strange behavior when printing a 4G+ integer on 32bits platform.

2018-11-15 Thread Tetsuo Handa
I received a comment from Peter John Acklam (current bigint maintainer). Forwarded Message Date: Wed, 14 Nov 2018 20:08:27 +0100 Hello This has actually nothing to do with Math::BigInt. The issue here is that the conversion "u", converts a number to an unsigned integer before t

Re: Strange behavior when printing a 4G+ integer on 32bits platform.

2018-11-14 Thread sisyphus
On Thu, Nov 15, 2018 at 1:49 AM Tetsuo Handa < penguin-ker...@i-love.sakura.ne.jp> wrote: > 32bits userspace on 64bits kernel: > # truncate -s 9223372036854775807 test > # perl -e 'use File::stat; my $sb = lstat("test"); printf("%s\n", $sb->size);' > 9.22337203685478e+18 > # perl -e 'use File::sta

Re: Strange behavior when printing a 4G+ integer on 32bits platform.

2018-11-14 Thread Tetsuo Handa
On 2018/11/14 21:46, sisyphus wrote: > On Wed, Nov 14, 2018 at 10:20 PM Tetsuo Handa > wrote: > >> Even on 32bit environments (at least for Linux), lstat() calls 64bit version > Here is some test results on Linux. 32bits userspace on 32bits kernel: # truncate -s 17592186044415 test # perl -e

Re: Strange behavior when printing a 4G+ integer on 32bits platform.

2018-11-14 Thread sisyphus
On Wed, Nov 14, 2018 at 10:20 PM Tetsuo Handa < penguin-ker...@i-love.sakura.ne.jp> wrote: > Even on 32bit environments (at least for Linux), lstat() calls 64bit version When I check on Windows, I find that the value is actually an NV (not an IV as I had expected). I expect it's the same for you,

Re: Strange behavior when printing a 4G+ integer on 32bits platform.

2018-11-14 Thread Tetsuo Handa
On 2018/11/14 19:59, sisyphus wrote: > On Wed, Nov 14, 2018 at 9:08 PM Tetsuo Handa > wrote > >> how can I pass $sb->size to Math::BigInt->new() as a string (assuming that >> $sb->size is an integer) ? > > To answer the question, you can do: > > my $x = $sb->size; > $value = Math::BigInt->ne

Re: Strange behavior when printing a 4G+ integer on 32bits platform.

2018-11-14 Thread sisyphus
On Wed, Nov 14, 2018 at 9:08 PM Tetsuo Handa < penguin-ker...@i-love.sakura.ne.jp> wrote > how can I pass $sb->size to Math::BigInt->new() as a string (assuming that $sb->size is an integer) ? To answer the question, you can do: my $x = $sb->size; $value = Math::BigInt->new("$x"); But doing so

Re: Strange behavior when printing a 4G+ integer on 32bits platform.

2018-11-14 Thread Tetsuo Handa
Hello, sisyphus. Thank you for your answer. > That can fail if $value is so big that it requires more than 15 decimal > digits to express it accurately. I want to use like (...snipped...) my $sb = lstat($file) || next; next unless (S_ISREG($sb->mode) && $sb->size); (...snipped...) $cu

Re: Strange behavior when printing a 4G+ integer on 32bits platform.

2018-11-13 Thread sisyphus
On 11/13/2018 8:07 AM, Tetsuo Handa wrote: > Hello. > > I want to represent up to a few hundreds gigabytes for file size. > > On 32bits platform, I noticed that > >my $value = ...; >printf("%u\n", $value); > > prints 4294967295 if $value >= 4294967295 whereas > >my $value = ...; >pr

Re: Strange behavior when printing a 4G+ integer on 32bits platform.

2018-11-13 Thread Mike Flannigan
I don't have an answer for you, but I find this interesting.  I note the same issue in 64bit up near 18446744073709551615 I'm guessing the guy who wrote Math::BigInt may have the answer. Mike On 11/13/2018 8:07 AM, Tetsuo Handa wrote: Hello. I want to represent up to a few hundreds gigaby