Take the following code:
long longInteger = 42;
int normalInteger = 23;
object rem = longInteger % normalInteger;
If rem
is the remainder of longInteger / normalInteger
, shouldn't the remainder always be bounded by the smaller sized "int", the divisor? Yet in C#, the above code results in rem
being a long
.
Is it safe to convert rem
to int
without any loss of data?
int remainder = Convert.ToInt32(rem);