Fix ScalaNumber-related bugs in Complex/Quaternion.

These problems were originally caught by Franco Callagari
and reported on IRC. The solution here should also work
for other generic number types like Jet.