Как умножить/разделить на дробное число?

backoff

Client
Регистрация
20.04.2015
Сообщения
5 925
Благодарностей
6 389
Баллы
113
есть снип
C#:
int timeStart = int.Parse(project.Variables["timeStart"].Value);
int timeNow = int.Parse(project.Variables["timeNow"].Value);
int coefficient = int.Parse(project.Variables["coefficient"].Value);
int tryes = int.Parse(project.Variables["tryes"].Value);

return (timeNow - timeStart) / 2592000 * coefficient * tryes;
где coefficient = 1,5 (так тоже пробовал "1.5" через точку)

выдает ошибку, я так понимаю работает только с целыми числами, подскажите что надо заменить у коэффициента, чтоб заработало и делило на 1,5...0,2 и тп

ps \ можно конечно умножать там 15/10 но это бред )
 

backoff

Client
Регистрация
20.04.2015
Сообщения
5 925
Благодарностей
6 389
Баллы
113
ответ

C#:
int timeStart = int.Parse(project.Variables["timeStart"].Value);
int timeNow = int.Parse(project.Variables["timeNow"].Value);
double coefficient = Convert.ToDouble(project.Variables["coefficient"].Value);
int tryes = int.Parse(project.Variables["tryes"].Value);

return (timeNow - timeStart) / 2592000 * coefficient * tryes;
 

viol2021

Client
Регистрация
12.01.2021
Сообщения
481
Благодарностей
179
Баллы
43
есть снип
C#:
int timeStart = int.Parse(project.Variables["timeStart"].Value);
int timeNow = int.Parse(project.Variables["timeNow"].Value);
int coefficient = int.Parse(project.Variables["coefficient"].Value);
int tryes = int.Parse(project.Variables["tryes"].Value);

return (timeNow - timeStart) / 2592000 * coefficient * tryes;
где coefficient = 1,5 (так тоже пробовал "1.5" через точку)

выдает ошибку, я так понимаю работает только с целыми числами, подскажите что надо заменить у коэффициента, чтоб заработало и делило на 1,5...0,2 и тп

ps \ можно конечно умножать там 15/10 но это бред )
double coefficient = double.Parse(project.Variables["coefficient"].Value);
 
  • Спасибо
Реакции: djaga и backoff

Кто просматривает тему: (Всего: 1, Пользователи: 0, Гости: 1)