32-bit system left overflow, 64-bit system does not overflow, can retain 32 left overflow results in 64-bit system

Source: Internet
Author: User
echo 83661<<15;//32 System results: 1553563648


echo 83661<<15;//64 System results: 2741403648


Want to keep 32 overflow result in 64-bit system, ask how to do, little brother think not understand, ask you big.


Reply to discussion (solution)

$n = 83661<<15;printf ("Signed:%d unsigned:%u binary:%032b", $n, $n, $n);

Signed:-1553563648 unsigned: 27,414,036,482 binary: 10100011011001101000000000000000

$n = 83661<<15;printf ("Signed:%d unsigned:%u binary:%032b", $n, $n, $n);

Signed:-1553563648 unsigned: 27,414,036,482 binary: 10100011011001101000000000000000



Big Hello, in 64 the machine carried out under.
$n = 83661<<15;printf ("%d", $n);//The result is still 2741403648.

Don't you get it?
They're one thing.

Don't you get it?
They're one thing.



Big, can pass
$n = 83661<<15;
Get this value on a 64-bit machine: 1553563648

echo  2741403648-0x100000000;
-1553563648

echo  2741403648-0x100000000;
-1553563648



Thank you greatly, my problem solved.
Displacement problem is not very familiar, we have to cram this knowledge.
  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.