try this:
$ X=0xf0000000
$ printf "0x%x\n" $((X>>1))
0x78000000
> How about removing the logical commands?
If you can show me how to do an unsigned right shift, I'd be happy to
consider it :) (though it adds almost no cost)
$ X=0x8000000000000000
$ printf "0x%x\n" $((X>>1))
0xc000000000000000
--
You know what I hate about people who criticize you? They criticize
what you say, but they never give you credit for how loud you say it.
-- Stephen Colbert to Bill O'Reilly
In my own scripts I have used both forms. I don't think the cost is
significant enough to eliminate the tools, but yes, they are largely
redundant (not bts and btr equivalent though :)
--
More specifically, ever C implementation I know of does sign extension
on unsigned right shift.
-2 = 0xfffffffe
-2 / 2 = -1
-1 0xffffffff
So sign extension is correct arithmetically. I just wish there was a
way to set unsigned mode. But as far as I know, nope.