But it is not -1.ffff it is -0.0001

In 16:16 fixed point:

0.5 is represented by 0x00008000;
1.0 is represented by 0x00010000;
-1 is represented by 0xffff0000.
-1.5 is represented by 0xffff8000.

This again highlights the issue:

#include <stdio.h>

void main( void )
{
int i = 0xffff8000;
printf( "%d\n", i >> 16 );
printf( "%d\n", i / 0x10000 );
}

The shift gives the result of -1, the divide gives 0.

You can do it with a divide, but it's ugly and only really works for the 16:16 case: (short)((unsigned int)i / 0x10000). The problem with the divide method is you need to do an unsigned divide with a sign extended result.

Phill


_______________________________________________ Xmame mailing list [EMAIL PROTECTED] http://toybox.twisted.org.uk/mailman/listinfo/xmame

Reply via email to