This operator case is surprisingly not necessarily mathematically trivial to describe formally because you often end up getting into the Dirac delta functions/continuous spectrum: as mentioned at: mathematical formulation of quantum mechanics