0

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

1085 << 24 = 1023410176

PHP:

1085 << 24 = 18203279360
1
  • js bit operations are as if on 32bit int. I dont know about php, 1085 << 24 goes beyond 32bit. Commented May 24, 2018 at 21:00

1 Answer 1

0

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

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

Difference in the results of operations bitwise between javascript and php

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.