efficient range conversion functions. fixes #2978