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

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

Thread Previous
From:
Sisyphus
Date:
February 17, 2015 03:11
Subject:
[perl #123851] "use integer" behaving oddly for large unsigned values
Message ID:
rt-4.0.18-19852-1424142690-624.123851-75-0@perl.org
# New Ticket Created by  "Sisyphus" 
# Please include the string:  [perl #123851]
# in the subject line of all future correspondence about this issue. 
# <URL: https://rt.perl.org/Ticket/Display.html?id=123851 >


Hi,

On all recent perls that I've tried ,including blead, 5.18.0 and 5.20.0, on 
linux and windows I'm getting stuff such as:

$ perl -Minteger -le '$x = 10_000_000_000_000_000_011; print $x; print $x / 
10;'
10000000000000000011
-844674407370955160

The actual perl configuration doesn't seem to matter except that ivsize has 
to be 8, and the numerator is larger than 2 ** 63.

Similarly, if ivsize is 4, and the numerator is greater than 2 ** 31 I get 
such outputs as:

C:\>perl -Minteger -le "$x = 3147483661; print $x; print $x / 10;"
3147483661
-114748363

I can't see anything in the integer documentation that explains this.
The only reference I see there in relation to signed/unsigned issues 
pertains to the bitwise operators.

Cheers,
Rob



Thread Previous


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