title: Addition of big decimal values in javascript for calculating distance on google map
body: <p>I am a fresher in coding and working on web designing on googlemap. I have a problem in finding total distance covered by user because i am using a formula for finding distance and then adding this distance one by one.The distance is like 0.41384640620101654 so when i am adding number of values of this type it is giving 0 or error.
  here is my code  </p>
  
  <pre class="lang-php prettyprint-override"><code>      getDistance();
  
               var mn = 0.00;
              function getDistance()
               {
  
  
                   for (var i = 0; i &lt; polyline_data.length-1; i++)
               {
                   $lngfrom = polyline_data[i].lng;
                   $lngto = polyline_data[i+1].lng;
                   $latfrom = polyline_data[i].lat;
                   $latto = polyline_data[i+1].lat;
                   $theta = $lngfrom - $lngto;
                      var pi = Math.PI;
                      var x = $latfrom * (pi/180);
                      var y = $latto * (pi/180);
                      var z = $theta * (pi/180);
                   var dist = new Array();        
                   var distance = Math.sin(x) * Math.sin(y)+ Math.cos(x) * Math.cos(y) * Math.cos(z);
                   distance = Math.acos(distance);
                   distance = distance*(180/pi);
  
  
                  var miles = distance * 60 * 1.8515;
                   distance = miles * 1.609344;
                    distance = parseFloat(distance);
                    //distance = Math.round(distance);
                    //dist = dist.push(distance);
                    //distance+=distance;
  
  
          console.log(distance);
  
      //console.log(all);
  
              //console.log(distance);
               }
  
  
  
      //var all = new Array();
  
      //for(j=0;j&lt;polyline_data.length-1;j++)
      //{
          //all[j]=distance;
      //}
          //console.log(all);
  
  
               } 
  </code></pre>