c - Partial, or wrapped multiplication - can anyone identify this function? -
I'm hoping for insights on how this looks like partial multiplication. #define LOW (x) ((x) & amp; 0xffffffff) #define HIGH (x) ((x)> 32) unsigned longer NotMultiply (unsigned) Long long x, unsigned long y) {return high (x) * high (y) + less (x) * less (y); }
This function is repeated repeatedly, as follows:
Unsigned long DoBusyWork (unsigned long long X, unsigned long Up to y, int n) {while (n--) x = notmultiply (x, y); Return x; } Is there a shortcut to calculate this result?
For this case where x is == y?
Any link will be helpful for more information ..
A strange hash Sounds like calculation. It takes the lowest 32 bits of the two numbers, multiplying it, takes 32 bits up (they are taken to the lower position) and multiplies them, and gives back the yoga.
I do not think you can make it simple, but maybe faster. You can break the loop if it returns the same value.
Unsigned long DoBusyWork (unsigned long-term, unsigned long y, int n) {long last x = x; While (n--) {x = notMultiply (x, y); Break if (x == last X); Previous X = x; } Return x; } I do not know if there is a high chance of ending the loop.
Comments
Post a Comment