Accurate mass spectrometry of trapped ions