coderage Posted June 2, 2007 Share Posted June 2, 2007 Hi i am doing some floating point, trignometric calculations and i get "nan" as a result value or -1.#IND as a result value for some starting values. what is this ? please explain. Link to comment https://forums.phpfreaks.com/topic/53983-1ind-nan-error/ Share on other sites More sharing options...
chigley Posted June 2, 2007 Share Posted June 2, 2007 Can you post your code please? Link to comment https://forums.phpfreaks.com/topic/53983-1ind-nan-error/#findComment-266860 Share on other sites More sharing options...
coderage Posted June 2, 2007 Author Share Posted June 2, 2007 Heres the code, the $diff variable gets the output value (sometimes) -1.#IND and if i use echo round($diff,2); it shows "nan" on screen $sin_dlat1 = sin($dlat1); $sin_dlat2 = sin($dlat2); $cos_dlat1 = cos($dlat1); $cos_dlat2 = cos($dlat2); $cos_long_diff = cos($dlong2 - $dlong1); $diff = acos($sin_dlat1*$sin_dlat2 + $cos_dlat1*$cos_dlat2*$cos_long_diff); Link to comment https://forums.phpfreaks.com/topic/53983-1ind-nan-error/#findComment-266864 Share on other sites More sharing options...
chigley Posted June 2, 2007 Share Posted June 2, 2007 Where are $dlat1, $dlat $dlong2 and $dlong1 defined? Link to comment https://forums.phpfreaks.com/topic/53983-1ind-nan-error/#findComment-266865 Share on other sites More sharing options...
coderage Posted June 2, 2007 Author Share Posted June 2, 2007 they are initiated to -1. they get latitude and lontitude values from database, their format is Lat: 1234.1234 , Long: 2345.4567 This problem arises mainly when both $dlat1 and $dlat2, $dlong1 and $dlong2 are same. Link to comment https://forums.phpfreaks.com/topic/53983-1ind-nan-error/#findComment-266867 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.