Make negative numbers positive, shift them and make them negative again:
sub SRshift { $_[0] < 0 ? -( -$_[0] >> $_[1] ) : $_[0] >> $_[1] }
Should work on any platform regardless of native integer size.
In reply to Re: Implementing a signed/sign-propagating right bitwise shift
by BrowserUk
in thread Implementing a signed/sign-propagating right bitwise shift
by LonelyPilgrim
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |