07.12.11 06:03, Steven D'Aprano написав(ла):
long newSeed = (seed& 0xL) * 0x41A7L;
while (newSeed>= 0x8000L) {
newSeed = (newSeed& 0x7FFFL) + (newSeed>>> 31L);
}
seed = (newSeed == 0x7FFFL) ? 0 : (int)newSeed;
seed = (seed & 0x) * 0x41A7 % 0x7FFF
--
Steven D'Aprano wrote:
> I have some bit-twiddling code written in Java which I am trying to port
> to Python. I'm not getting the same results though, and I think the
> problem is due to differences between Java's signed byte/int/long types,
> and Python's unified long integer type. E.g. Java's >
On 12/6/11, Steven D'Aprano wrote:
> I have some bit-twiddling code written in Java which I am trying to port
> to Python.:
>
> long newSeed = (seed & 0xL) * 0x41A7L;
> while (newSeed >= 0x8000L) {
> newSeed = (newSeed & 0x7FFFL) + (newSeed >>> 31L);
> }
> seed = (newSeed =
I have some bit-twiddling code written in Java which I am trying to port
to Python. I'm not getting the same results though, and I think the
problem is due to differences between Java's signed byte/int/long types,
and Python's unified long integer type. E.g. Java's >>> is not exactly
the same a