add functions for magnitude conversion