I am trying to convert a C programme to a scrip basic language.

The C programme is fairly simple but produces unexpected results - it is the unxpected result that I would like to emulate with script basic.

I am hoping someone can explain the mechanism that the C programme is using to come up with the unexpected result, then I will try and put that in practice in script basic using the available functions.

The C programme:

Code:

main()
{
unsigned int crc;
crc=-248625283;
printf("crc before div by 256 %d\n", crc);
printf("crc is a negative number to start with \n");
crc=crc/256;
printf("crc after divide by 256 and assigned to an unsigned integer equals %d decimal \n", crc);
}

Normally if you divide -248625283 by 256 you would get a result of -971192 (integer)

Similarly if you divide 248625283 by 256 you would get a result of 971192.

The programme above gives a result of 15806023 . I expect this is related to assigning a negative number to a unsigned integer. What I need to know is how to get this result (15806023) using basic maths functions.

I hope someone can help explain the mechanism that gives 15806023 when dividing -248625283 by 256.