0

I have come upon this problem.

I am working in android and I am trying to calculate a int value.

I can use this code:

int newCenterY = getHeight() * 3 / 5;

and it will work fine.

However, if I use this code:

int newCenterY = (3 / 5) * getHeight();

then android studio will warn me with: *(3 / 5) * getHeight(); can be replaced with 0* and it will indeed result in 0.

Are those two pieces of code not the same thing?

Linxy
  • 2,525
  • 3
  • 22
  • 37

0 Answers0