Юрий Топчий Юрий Топчий - 1 year ago 116
PHP Question

Generating unique integer ID from two integer id's

Given 2 integers a and b (positive). Is there any formula / method for generating unique ID number?

note: result from f(a,b) and f(b,a) should be the same.Solution should be efficient. No matter it would be a scratch of PHP code or algorithm.

Answer Source

Example for 32-bit numbers (using left shift)

Int64Code = Max(a, b) + (Min(a, b) << 32)
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download