title: Nan in calculating Distance using Latitude and Longitude
body: <p>I am calculating the Distance between two Latitudes and Longitudes. I get the results for some distances but sometimes,I get the results as NAN. </p>
  
  <p>This is the Latitude and Longitude which I have got for 2 places.</p>
  
  <p>For eg:
  38.655553,-121.091611</p>
  
  <p>38.654875,-121.091324</p>
  
  <p>I am using the below code to calculate the distance with reference to the below link</p>
  
  <p><a href="https://stackoverflow.com/questions/8049612/calculating-distance-between-two-geographic-locations">Calculating distance between two geographic locations</a></p>
  
  <pre><code>public static double distanceBetween (double currentLat2, double currentLong2, double mallLat2, double mallLong2)
  {
       float pk = (float) (180/3.14169);
  
          double a1 = currentLat2 / pk;
          double a2 = currentLong2 / pk;
          double b1 = mallLat2 / pk;
          double b2 = mallLong2 / pk;
  
          double t1 = FloatMath.cos((float) a1)*FloatMath.cos((float) a2)*FloatMath.cos((float) b1)*FloatMath.cos((float) b2);
          double t2 = FloatMath.cos((float) a1)*FloatMath.sin((float) a2)*FloatMath.cos((float) b1)*FloatMath.sin((float) b2);
          double t3 = FloatMath.sin((float) a1)*FloatMath.sin((float) b1);
          double tt = Math.acos(t1 + t2 + t3);
  
         return 6366000*tt;               
  }
  </code></pre>
  
  <p>Any Help?</p>
  
  <p>Thanks.</p>