PHP和JS的按位运算不同 [英] Bitwise operations PHP and JS different

查看:75
本文介绍了PHP和JS的按位运算不同的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

为什么php和js对同一件事给出不同的结果:JS:

Why does php and js give different results to the same thing: JS:

1085 << 24 = 1023410176

PHP:

1085 << 24 = 18203279360

推荐答案

JavaScript中按位运算的操作数始终被视为int32,而在PHP中并非如此.

The operands of a bitwise operation in JavaScript are always treated as int32, and in PHP this is not the case.

在PHP中,这些位不会被截断,因为它不会被视为32位整数.

And in PHP, the bits do not get truncated because it is not treated as a 32-bit integer.

按位运算结果的差异在javascript和php之间

这篇关于PHP和JS的按位运算不同的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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