in reply to Re: Implement Arithmetic Shift Right for signed number in perl
in thread Implement Arithmetic Shift Right for signed number in perl

That's not the correct way, It will not be true every time, this time you knew the result. I figured out the correct way
my $Rm = 0xAAAAAAAA; my $Rd = $Rm >> 31; # any shift amount from 0 top 31 for 32 bit data. $Rd |= 0xffffffff << (32 - 31); #it can be (32 - any shift amount) $Rd = $Rd & 0xffffffff; #mask bits more than 32 printf "Rd = 0x%x\t Rb = %x\n",$Rd, $Rm;
Output
Rd = 0xffffffff Rb = 0xaaaaaaaa