ДЛя этого есть мат методы https://msdn.microsoft.com/ru-ru/library/system.math_methods(v=vs.110).aspx