-2

I have 2 input int values that need do be divided and sen back as a string with 6 decimals.

int a = 240
int b = 1440.

I want to divide them and send back a text string with 0,166667

I have tried many code examples but none have worked.

Christoph Fink
  • 22,727
  • 9
  • 68
  • 113
Patrik Blå
  • 79
  • 1
  • 8

1 Answers1

1

You need to convert at least one to a decimal value:

double result = (double)a / b;

or

decimal result = (decimal)a / b;

On "decimal vs. double" see THIS question.

Community
  • 1
  • 1
Christoph Fink
  • 22,727
  • 9
  • 68
  • 113