Is there an easy way to find two values โ€‹โ€‹that, when multiplied together, create an accurate bitmap?

For testing purposes, I need to find two 64-bit integer values โ€‹โ€‹that are exactly multiplied by a 128-bit intermediate value with a specific bit pattern. Obviously I can generate the intermediate value I want and divide by random values โ€‹โ€‹until I find a combination that works, but is there a more efficient way?

+2


source to share


3 answers


This problem sounds like a whole factorization . Unfortunately, no fast algorithms are known, but after looking at this Wikipedia page it seems that there are some (possibly complex) algorithms that are faster than trial division.



+7


source


I was going to post the same as j_random_hacker. I'll just add that if a 128 bit number is prime or has a base ratio greater than 64 bits then there will be no solution to your problem.



+4


source


And I'll just add to the previous comment: if a 128-bit number has a base ratio greater than 64 bits, then it certainly has a ratio less than 64 bits :)

+1


source







All Articles