|
|
Subscribe / Log in / New account

Undefined behaviour

Undefined behaviour

Posted Sep 10, 2018 22:28 UTC (Mon) by anselm (subscriber, #2796)
In reply to: Undefined behaviour by Wol
Parent article: C considered dangerous

The main difference between an arithmetic shift to the right and a logical shift to the right is that the logical shift will make the MSB zero while the arithmetic shift will keep the MSB (the sign of a signed number) whatever it was before the shift. This doesn't make a huge amount of sense when shifting to the left, because the LSB in a signed number isn't special, so processor makers often didn't bother with arithmetic shifts to the left (especially with the simpler late-20th-century-vintage CPUs).


to post comments


Copyright © 2025, Eklektix, Inc.
Comments and public postings are copyrighted by their creators.
Linux is a registered trademark of Linus Torvalds