develooper Front page | perl.perl5.porters | Postings from February 2015

[perl #123851] "use integer" behaving oddly for large unsigned values

Thread Previous | Thread Next
From:
Tony Cook via RT
Date:
February 17, 2015 05:35
Subject:
[perl #123851] "use integer" behaving oddly for large unsigned values
Message ID:
rt-4.0.18-26690-1424151337-1898.123851-15-0@perl.org
On Mon Feb 16 20:48:24 2015, ikegami@adaelis.com wrote:
> bigint says " Integer constants are created as proper BigInts." To me, that
> means the following two snippets should be equivalent:
> 
> $ perl -Minteger -le '$x = 10_000_000_000_000_000_011; print $x; print $x /
> 10;'
> 10000000000000000011
> -844674407370955160
> 
> $ perl -MMath::BigInt -le '$x =
> Math::BigInt->new("10_000_000_000_000_000_011"); print $x; print $x /
> Math::BigInt->new("10");'
> 10000000000000000011
> 1000000000000000001
> 
> So I agree with Sisyphus. Something isn't right.

bigint has a bigger range than the documented range of "-(2**63) .. (2**63-1) on 64-bit architectures".

There are examples in perldoc integer documenting the wrapping behaviour.

What behaviour do you expect given the documentation?

Tony


---
via perlbug:  queue: perl5 status: open
https://rt.perl.org/Ticket/Display.html?id=123851

Thread Previous | Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About