• Welcome to Dark Bit Factory & Gravity.
 

SAR?

Started by Stonemonkey, May 30, 2007

Previous topic - Next topic

0 Members and 0 Guests are viewing this topic.

Stonemonkey

Is there any way to do SAR without resorting to asm?

Cheers,
Fryer.

Jim

If you're working with signed values it does arithmetic shifts automatically.
ie

#include <stdio.h>

int main(void)
{
  int a=0x80000000;
  a = a >> 16;
  printf("%d %08X\n", a, a);
  return 0;
}

gives

-32768 0xFFFF8000


Jim
Challenge Trophies Won:

Stonemonkey

DOH! Thanks Jim.