|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
hi,
i want to convert a javascript programm to php an encountered the following problem: there is a part in the javascript file, where an XOR operation is performed by: [javascript:] t2=959077477; m=7127917138; x1 = t2 ^ m; alert(x1); -> resulting in: -1846460873 (t2 and m are variables, i just used the values where the problem occures) when i convert this to php: [php:] $t2=959077477; $m=7127917138; $x1 = $t2 ^ $m; echo "<br>".$t2." XOR ".$m." = ".$x1; the result is: -959077478 does anyone know why those 2 values are diffrent ? is there a problem with the length of the numbers (if yes how can i solve it) thanks, mike |
|
#2
|
|||
|
|||
|
I'm not a pro at this, but I'd say your problem is with the floating point precission of integers... those are large numbers you're throwing around, and when you raise one to the other, it's getting huge... Don't know how exactly to solve that...
Perhaps look up a better algorithm using google? |
|
#3
|
|||
|
|||
|
thanks again on that one...
i thought so myself. i used a different server an there it worked (it also did on my old test server back home). so i kinda solved the problem by avoiding it *g* mike |
![]() |
| Viewing: Dev Shed Forums > Web Design > JavaScript Development > XOR Problem when converting from JavaScript to PHP |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|
|