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. Quote 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? Quote 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); Quote 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? Quote 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. Quote Link to comment https://forums.phpfreaks.com/topic/53983-1ind-nan-error/#findComment-266867 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.