b_hole

03-19-2007, 12:21 PM

Hi,

I'm trying to convert some JS functions to PHP.

My main problem is tyhat I didn't wrote the JS, so I'm not fully understand it.

Anyway, here's a given JS function for example:

a -= b; a -= c; a ^= (zeroFill(c,13));

b -= c; b -= a; b ^= (a<<8);

c -= a; c -= b; c ^= (zeroFill(b,13));

a -= b; a -= c; a ^= (zeroFill(c,12));

b -= c; b -= a; b ^= (a<<16);

c -= a; c -= b; c ^= (zeroFill(b,5));

a -= b; a -= c; a ^= (zeroFill(c,3));

b -= c; b -= a; b ^= (a<<10);

c -= a; c -= b; c ^= (zeroFill(b,15));

var ret = new Array(a,b,c);

My PHP is this:

$a=$a - $b;

$a=$a - $c;

$a=$a ^ (zeroFill($c, 13));

$b=$b - $c;

$b=$b - $a;

$b=$b ^ ($a<<8);

$c=$c - $a;

$c=$c - $b;

$c=$c ^ (zeroFill($b, 13));

$a=$a - $b;

$a=$a - $c;

$a=$a ^ (zeroFill($c, 12));

$b=$b - $c;

$b=$b - $a;

$b=$b ^ ($a<<16);

$c=$c - $a;

$c=$c - $b;

$c=$c ^ (zeroFill($b, 5));

$a=$a - $b;

$a=$a - $c;

$a=$a ^ (zeroFill($c, 3));

$b=$b - $c;

$b=$b - $a;

$b=$b ^ ($a<<10);

$c=$c - $a;

$c=$c - $b;

$c=$c ^ (zeroFill($b, 15));

$ret=Array($a, $b, $c);

I can't see a reason for, but ret and $ret are not the same (checked using a loop to print all values).

Help please?

I'm trying to convert some JS functions to PHP.

My main problem is tyhat I didn't wrote the JS, so I'm not fully understand it.

Anyway, here's a given JS function for example:

a -= b; a -= c; a ^= (zeroFill(c,13));

b -= c; b -= a; b ^= (a<<8);

c -= a; c -= b; c ^= (zeroFill(b,13));

a -= b; a -= c; a ^= (zeroFill(c,12));

b -= c; b -= a; b ^= (a<<16);

c -= a; c -= b; c ^= (zeroFill(b,5));

a -= b; a -= c; a ^= (zeroFill(c,3));

b -= c; b -= a; b ^= (a<<10);

c -= a; c -= b; c ^= (zeroFill(b,15));

var ret = new Array(a,b,c);

My PHP is this:

$a=$a - $b;

$a=$a - $c;

$a=$a ^ (zeroFill($c, 13));

$b=$b - $c;

$b=$b - $a;

$b=$b ^ ($a<<8);

$c=$c - $a;

$c=$c - $b;

$c=$c ^ (zeroFill($b, 13));

$a=$a - $b;

$a=$a - $c;

$a=$a ^ (zeroFill($c, 12));

$b=$b - $c;

$b=$b - $a;

$b=$b ^ ($a<<16);

$c=$c - $a;

$c=$c - $b;

$c=$c ^ (zeroFill($b, 5));

$a=$a - $b;

$a=$a - $c;

$a=$a ^ (zeroFill($c, 3));

$b=$b - $c;

$b=$b - $a;

$b=$b ^ ($a<<10);

$c=$c - $a;

$c=$c - $b;

$c=$c ^ (zeroFill($b, 15));

$ret=Array($a, $b, $c);

I can't see a reason for, but ret and $ret are not the same (checked using a loop to print all values).

Help please?