Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

<?
    class int64{
        var $h;
        var $l;
        function int64($h, $l)
        {
            $this->h = $h;
            $this->l = $l;
        }
    }
    function int64rrot(int64 $dst, int64 $x, $shift)
    {
        $dst->l = ($x->l >> $shift) | ($x->h << (32-$shift));
        $dst->h = ($x->h >> $shift) | ($x->l << (32-$shift));
        print_r($dst);
    }
    $a =  new int64(1779033703,-205731576);
    $b =  new int64(1779033701,-205731572);
    int64rrot($a,$b,19);
?>
<script type="text/javascript">
    function int64rrot(dst, x, shift)
    {
        dst.l = (x.l >>> shift) | (x.h << (32-shift));
        dst.h = (x.h >>> shift) | (x.l << (32-shift));
        console.log(dst);
    }
    function int64(h, l)
    {
      this.h = h;
      this.l = l;
    }
    a =  new int64(1779033703,-205731576);
    b =  new int64(1779033701,-205731572);
    int64rrot(a,b,19);
</script>

Output in screen (by PHP:)

int64 Object ( [h] => -1725854399 [l] => -393 ) 

Output in console (by Javascript) (Correct one):

int64 { h=-1725854399, l=1020051063}

I am trying to correct this whole day. but couldn't. What modification do I need in PHP code to get the answer as javascript?

I Want to get javascript output using php

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
248 views
Welcome To Ask or Share your Answers For Others

1 Answer

You used a >>> operator in JavaScript. It means logical rightshift. PHP Does not have this, this is the error.

To get the same output:

Change the operator in JavaScript from '>>>' to '>>' or

implement a logical rightshift function in PHP.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...