develooper Front page | perl.perl5.porters | Postings from May 2008

Re: [perl #53784] 64-bit Integers -- inexact division gives odd resultwhen is large

Thread Previous | Thread Next
From:
Dominic Dunlop
Date:
May 7, 2008 05:53
Subject:
Re: [perl #53784] 64-bit Integers -- inexact division gives odd resultwhen is large
Message ID:
8BFD7D48-F992-4E04-A488-2D78A3EFF0BA@mac.com
On 2008–05–06, at 19:58, Chris Hall (via RT) wrote:

Good news -- from the point of view of repeatability: I get the same  
results as you when running your test program on a 64-bit blead perl  
(patchlevel 33783).

> The first section shows the effect.  Where the integer division is  
> exact we
> get the right integer result.  Where it is not exact, the result is  
> floated,
> with hopeless loss of significance !


Bad news from the point of view of understanding the phenomenon: I get  
the same results as you when I put -Minteger on the 64-bit perl  
command line; that is, when arithmetic operations are carried out with  
machine integers and fractional parts are truncated. Same if I put - 
Mbigint, replacing all machine arithmetic with arbitrary precision  
integer operations.

These modules appear to be behaving themselves:

domo:64-bit_perl-current$ ./perl -lwe '$x=2**60 + 3; print $x/2 - 2**59'
0
domo:64-bit_perl-current$ ./perl -Ilib -Minteger -lwe '$x=2**60 + 3;  
print $x/2 - 2**59'
1
domo:64-bit_perl-current$ ./perl -Ilib -Mbigint -lwe '$x=2**60 + 3;  
print $x/2 - 2**59'
1

Can you say why I should be getting the same results from your test  
program in all three cases?
-- 
Dominic Dunlop



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