JavaScript按位运算符代码和Python按位运算符代码之间的区别 [英] difference between JavaScript bit-wise operator code and Python bit-wise operator code

查看:454
本文介绍了JavaScript按位运算符代码和Python按位运算符代码之间的区别的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经转换了JavaScript代码,该代码在该代码中使用按位运算符到Python代码,但是当我在JavaScript和Python中执行此操作时存在一个问题

I have converted JavaScript code which uses bit-wise operators in that code to Python code, but there is one problem when i do this in JavaScript and Python

412287 << 10

然后我在两种语言中得到 422181888 相同的结果。但当我在两者中这样做时

then I get this 422181888 same results in both languages. but when i do this in both

424970184 << 10

然后我在JavaScript中使用两种语言 1377771520 得到不同的结果Python中的 435169468416

then i get different results in both of the languages 1377771520 in JavaScript and 435169468416 in Python

任何人都可以帮我这个吗?
任何帮助将不胜感激。

can anybody help me with this? any help would be appreciated.

推荐答案

如果你想要java-script等价值,你可以做的是:

If you want the java-script equivalent value then what you can do is :

import ctypes

print(ctypes.c_int(424970184 << 10 ^ 0).value)

输出:

1377771520

这篇关于JavaScript按位运算符代码和Python按位运算符代码之间的区别的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆