This may have been asked already, but I was unable to find it on this forum. I had a general question about integer arithmetic in c++ when doing arithmetic on large integers.
unsigned int value = 500000;
value = (value * value) % 99;
The correct value to the above code would be 25, however when this is implemented in C++ I get a value of 90.
I looked at the disassembly and that gave me a slight idea as to why it may be coming back with an erroneous value, the disassembly is as follows
unsigned int value = 500000;
00D760B5 mov dword ptr [value],7A120h
value = ((value * value) % 99);
00D760BC mov eax,dword ptr [value]
00D760BF imul eax,dword ptr [value]
00D760C3 xor edx,edx
00D760C5 mov ecx,63h
00D760CA div eax,ecx
00D760CC mov dword ptr [value],edx
It appears to be placing it into a 32 bit register, and that is why the result is coming back erroneous.
Nevertheless, my question is how can I mimic the language to give me the correct answer? I'm sure there's an easy and straightforward way to do it but I'm drawing a blank.