You are doing integer division, so 25/100
is 0
, not 0.25
, and hence 0 * 70
is 0
. Since your result variable is also an int
it's unclear what result you are expecting, but you could reorder the operations to get a non-zero answer:
int WStoneCost = (PriceMethod.StoneCost * AP)/ 100 ;
It's still integer division, but with your inputs will divide 25*70 (1,750) by 100, which will give you 17.
If you want a floating-point decimal result, just use 100m
:
decimal WStoneCost = (PriceMethod.StoneCost * AP)/ 100m ;
Since the literal 100m
is a decimal
, then the compiler will use floating-point decimal division, which will give you a decimal
result.