How to display distance?

How to display distance? Is there a formula?

I have found some thread discussed on distance calculation. You can check,