Tuesday, November 11, 2008

Decimal division problem in C#

if you divide two int then the result is always integer even if you save it in Decimal.

int A = 32;
int B = 36;
decimal result = A / B;

then the result = 0

but if you use
decimal A = 32;
decimal B = 36;
decimal result = A / B;

then the result = 0.8888888888

No comments:

Post a Comment