If you want the precision to be preserved, then returning double is better. So, the proper change would be to change the return data type. I have merely fixed the compilation issue here.