develooper Front page | perl.perl5.porters | Postings from June 2016

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

From:
Dan Collins via RT
Date:
June 8, 2016 00:08
Subject:
[perl #53784] 64-bit Integers -- inexact division gives odd resultwhen is large
Message ID:
rt-4.0.18-10722-1465344526-1599.53784-14-0@perl.org
I have attempted to reproduce the original testcase, and 64-bit-all builds of both 5.20.0 and blead behave properly:

a =  0x0FEDCBA987654321 * 9 + i, for i = 0..9
  i:    d = int(a/9)    :        a/9           : a%9 : a - d*9
  0: 0x0FEDCBA987654321 :  1147797409030816545 :  +0 :    +0
  1: 0x0FEDCBA987654321 : 1.14779740903081655e+18 :  +1 :    +1
  2: 0x0FEDCBA987654321 : 1.14779740903081655e+18 :  +2 :    +2
  3: 0x0FEDCBA987654321 : 1.14779740903081655e+18 :  +3 :    +3
  4: 0x0FEDCBA987654321 : 1.14779740903081655e+18 :  +4 :    +4
  5: 0x0FEDCBA987654321 : 1.14779740903081655e+18 :  +5 :    +5
  6: 0x0FEDCBA987654321 : 1.14779740903081655e+18 :  +6 :    +6
  7: 0x0FEDCBA987654321 : 1.14779740903081655e+18 :  +7 :    +7
  8: 0x0FEDCBA987654321 : 1.14779740903081655e+18 :  +8 :    +8
  9: 0x0FEDCBA987654322 :  1147797409030816546 :  +0 :    +0
______________________________________________________________________
a =  0x0010000000000000 * 2 + i, for i = 0..3
  i:    d = int(a/2)    :        a/2           : a%2 : a - d*2
  0: 0x0010000000000000 :     4503599627370496 :  +0 :    +0
  1: 0x0010000000000000 :   4503599627370496.5 :  +1 :    +1
  2: 0x0010000000000001 :     4503599627370497 :  +0 :    +0
  3: 0x0010000000000001 :   4503599627370497.5 :  +1 :    +1

Unless anyone has a different understanding of this issue, we should write a test case and close this bug.



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