Hans W Borchers: Your definition is not equivalent. julia> sin(pi) 1.2246467991473532e-16
julia> sind(180) 0.0 julia> sinpi(1) 0 julia> sin(big(pi)) 1.096917440979352076742130626395698021050758236508687951179005716992142688513354e-77 with 256 bits of precision The answer for sin(pi) is somewhat correct, because float(pi) is not the π you know from mathematics. It is the closest representable *IEEE 754* floating point number. Ivar kl. 09:31:42 UTC+1 onsdag 5. februar 2014 skrev Hans W Borchers følgende: > > You could easily add these two lines of function definitions to your code. > > sind(x) = sin(degrees2radians(x)) > cosd(x) = cos(degrees2radians(x)) > > and your haversine function stands as is, not littered with conversions. > > > On Tuesday, February 4, 2014 6:55:13 PM UTC+1, Jacob Quinn wrote: >> >> As someone who doesn't have to work with the functions very often or deal >> with degrees/radians conversions, I actually have found it convenient to >> have the sind functions. It saves me time from having to remember what the >> conversion is or make my code uglier littered with degrees2radians() >> conversions, for example, in the following haversine distance calc. >> >> haversine(lat1,lon1,lat2,lon2) = 12745.6 * >> asin(sqrt(sind((lat2-lat1)/2)^2 + cosd(lat1) * cosd(lat2) * sind((lon2 - >> lon1)/2)^2)) >> >>