Now I'm try to convert some js code into java , there is a problem:
In js
46022*65535 = 3016051770
and
(46022*65535)|7867 = -1278910789
In java
46022*65535 = -1278915526 this is overflow
46022l*65535l = 3016051770 this is the same result to js
(46022*65535)|7867 = -1278910789 this one and the one below is the problem
(46022l*65535l)|7867l = 3016056507
So , why the |
operator will make two positive number to be nagtive number? What's the different between java and js when dealing with the int and long to do this operation?
And then , how to write java code compatible with js in this situation ?
Attention:I know the range of int and long , my problem is |
.
Aucun commentaire:
Enregistrer un commentaire