title: Java: questions about radians, Math.cos, Math.sin, double and long
body: <p>I need to implement the harvesine distance in my java code.</p>
  
  <p>I found this snippet in Javascript, and I need to convert it to java.</p>
  
  <ol>
  <li>How can I convert latitude and longitude to radians in Java ?</li>
  <li>Math.sin wants a double in Java. Should I pass the previously converted value in radians or not ?</li>
  <li>Math.sin and Math.cos return long. Should I declare a as long and pass it to Math.sqrt or convert it to double ?</li>
  </ol>
  
  <p>thanks</p>
  
  <pre><code>dLat = (lat2-lat1).toRad();
  dLon = (lng2-lng1).toRad(); 
  a = Math.sin(dLat/2) * Math.sin(dLat/2) +
      Math.cos(lat1.toRad()) * Math.cos(lat2.toRad()) * 
      Math.sin(dLon/2) * Math.sin(dLon/2); 
  c = 2 * Math.atan2(Math.sqrt(a), Math.sqrt(1-a)); 
  d = R * c;
  return d;
  </code></pre>