Bug introduced in 10.0.0 and fixed in 10.0.2
With Mathematica 10 for Mac, BitShiftRight
works properly on lists of up to 100000 numbers, but appears to give incorrect results when threaded over lists of 100001 or more:
v1 = Table[i, {i, 1, 100000}];
v2 = Table[i, {i, 1, 100001}];
s1 = BitShiftRight[v1];
s2 = BitShiftRight[v2];
s1[[1 ;; 10]]
s2[[1 ;; 10]]
Out[1070]= {0, 1, 1, 2, 2, 3, 3, 4, 4, 5} Out[1071]= {2, 4, 6, 8, 10, 12, 14, 16, 18, 20}
The error seems to occur for any BitShiftRight[n,k]
whenever n is a list exceeding 100000 values.
Mathematica 9 gives correct output:
v1 = Table[i, {i, 1, 100000}];
v2 = Table[i, {i, 1, 100001}];
s1 = BitShiftRight[v1];
s2 = BitShiftRight[v2];
s1[[1 ;; 10]]
s2[[1 ;; 10]]
Out[799]= {0, 1, 1, 2, 2, 3, 3, 4, 4, 5} Out[800]= {0, 1, 1, 2, 2, 3, 3, 4, 4, 5}
I have several notebooks that apply BitShiftRight[n,k]
to very large lists. The only Mathematica 10 workaround seems to be the equivalent IntegerPart[n/2^k]
that continues to work on very large lists, but is slower and requires rewriting previously working code. Otherwise I would need to stick with MM 9 for these notebooks.
Can anyone confirm this anomalous MM 10 output? Does it affect other platforms? Am I missing something simple, or is this a true MM 10 bug?
Thanks
Range[100001]; a = BitShiftRight[v[[;; 10]]]; b = BitShiftRight[v][[;; 10]]; a == b
isFalse
. $\endgroup$BitShiftLeft
works fine by the way. $\endgroup$