-2

when i want to get the result of 100/100000.. i got only 0.

Example

int one = 100;
int two = 100000;
int result = one/two;
toast(result);  //Result is 0
AskNilesh
  • 67,701
  • 16
  • 123
  • 163
Ninoo
  • 25
  • 6

1 Answers1

-1

Hey there "int" data type only stores integer values and not the decimals. So if you divide 3 with 2 you would get 1 as answer instead of 1.5 . Int just ignores the decimals .

You need to choose float or double data type for this to work.

Your variable named result must be declared and casted to float data type.

Appreciate the effort and mark this as answer if it helps you.....