Quote

d=acos(sin(lat1)*sin(lat2)+cos(lat1)*cos(lat2)*cos(lon1-lon2))

Here's my implementation in Java:

public static final double PI = 3.14159265; public static final double deg2radians = PI/180.0; double lat1 = latitude1 * deg2radians; double lat2 = latitude2 * deg2radians; double lon1 = longitude1 * deg2radians; double lon2 = longitude2 * deg2radians; // Williams gives two formulae; // this is the more accurate for close distances. // In practice, the two differed only in the 8th or 9th place, for // separations as small as 1 degree. radd=2*Math.asin(Math.sqrt(Math.pow(Math.sin((lat1-lat2)/2),2.0) + Math.cos(lat1)*Math.cos(lat2)*Math.pow(Math.sin((lon1-lon2)/2) ,2.0)));

Note that this assumes decimal latitude and longitude; if you have your coordinates as degrees, minutes, and seconds, you'll have to convert.

The Aviation Formulary is a great resource if you need to work with latitude and longitude. And given the number of applications these days that need to compute distances, and the ease with which you can get a latitude or longitude given an address (just try Google Maps, Yahoo!, or any of a number of services), the chances are you'll find yourself working with latitude and longitude sooner rather than later.