Hi Jassim Rahma,

Thank you for posting here.

As Castorix31 suggested, you can use ‘%’ to convert the formula.

Here’s the code:

double d = Math.Atan2(Math.Sin(lang_to_radians - long_from_radians) * Math.Cos(latt_to_radians),
(Math.Cos(latt_from_radians) * Math.Sin(latt_to_radians)) -
(Math.Sin(latt_from_radians) * Math.Cos(latt_to_radians) * Math.Cos(lang_to_radians - long_from_radians)))
% (2 * Math.PI);

Best Regards,

Xingyu Zhao

MSDN Community Support

Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to
MSDN Support, feel free to contact MSDNFSF@microsoft.com.