java - Returning zero when it shouldn't -
the method below keeps returning 0, , cannot figure out why! please help!
currentlocation.setlatitude(38.03211); currentlocation.setlongitude(-78.51002);
and longitude/latitude of if loc 38.03161, -78.51075,
public double getdistance(historicallocation loc) { return (double) math.abs(math.sqrt((currentlocation.getlatitude() - loc .getlatitude()) * (currentlocation.getlatitude() - loc.getlatitude()) + (currentlocation.getlongitude() - loc.getlongitude()) * (currentlocation.getlongitude() - loc.getlongitude()))); }
take squareroot of absolute value, not other way around. coming nan setting 0 or that.
(this fixed it)
Comments
Post a Comment