Numerical Underflow

    Date: 06/24/05 (PHP Community)    Keywords: php

    I'm doing some calculations in php, and seem to be having a problem with either overflow, or underflow (small # gets rounded to 0). It works for some values, but for others, gives me a huge number, usually in the billions. Is it possible in php to specify the use of a higher precision datatype, or how else can I avoid this problem in php?


    This is the function which seems to be causing the problem:

    //calculate the distance between two latitude, logitude coordinates. +ve is N,E
    function latlonradiandistance($lat1,$lon1, $lat2,$lon2){
    $r = 6378100; //radius of earth in meters
    return acos(cos($lat1)*cos($lon1)*cos($lat2)*cos($lon2) + cos($lat1)*sin($lon1)*cos($lat2)*sin($lon2) + sin($lat1)*sin($lat2)) * $r;
    }

    Source: http://www.livejournal.com/community/php/312254.html

« Transfer variables. || Input Variables - Accepted... »


antivirus | apache | asp | blogging | browser | bugtracking | cms | crm | css | database | ebay | ecommerce | google | hosting | html | java | jsp | linux | microsoft | mysql | offshore | offshoring | oscommerce | php | postgresql | programming | rss | security | seo | shopping | software | spam | spyware | sql | technology | templates | tracker | virus | web | xml | yahoo | home