How does repairing work?

Solution 1:

You get more uses.

According to the Minecraft Wiki article on it, the formula is:

floor( Item A uses + Item B uses + (Max uses / 10) )

So not only do you save inventory space by combining ("repairing") partially used tools, you actually get more uses out of the combined tool.

Solution 2:

According to Notch:

If item 1 has 10 uses left, and item 2 has 10 uses left, you'll end up with something like 25 uses in the final product.

And according to the wiki, the exact algorithm is:

floor(  Item A uses + Item B uses + (Max uses / 10)  )