Division operator numbers in c#

% operator is remainder operator. It calculates the remainder when you divide first operand to second one.

10 = 25 * 0 + 10

You need to use / operator with at least one floating point number to get 0.4 as a result. Otherwise, this operators calculates integer division for two integer operands and it’s disregards fractional part.

10.0 / 25 = 0.4
10.0 / 25.0 = 0.4
10 / 25.0 = 0.4

Leave a Comment