How to produce a unique number from combination of 2 numbers (in any order) in PHP? [closed]

No, at least not in general (though there may be if you specify some restrictions).

Assuming n-bit types, there are 2n possible values. But there are 22n possible pairs of values. Obviously there’s not a unique mapping from a pair to a value.

Of course, if you’re prepared to have an output type that’s wider than your input type, then this is trivial.

Leave a Comment