I tested your “divide_by_10 algorithm” on Microsoft Visual Studio 2012.

1 – I confirm that it works only for positive 16-bit integers, that is “unsigned short” integers from 0 to 65535.

2 – When i is equal to 81920 then the algorithm fail.

void test_divide_by_10 (void)

{

unsigned long r;

unsigned long r_2;

unsigned long i;

unsigned long constant;

int error;

/*

* I confirm that then i gets equal to 81920,

*/

error = 0;

constant = 0xCCCD;

for (i = 0; i > 16) >> 3;

r_2 = (unsigned long) (i / 10);

if (r_2 != r)

{

error = 1; /* Put a breakpoint here */

}

}

}

Thanks for your work.

Enrico Migliore

]]>