


NOTE: When the divisor is 0, we get a math domain error. When dividend = 5 and divisor = -3 then the result is 2.0 When dividend = -5 and divisor =3 then the result is -2.0 The following examples would help to illustrate the above concepts: The Modulus Operation result is a floating point value even if the dividend and divisor are integer values.

If the dividend is negative, the result of the Modulus Operation is negative, and if it is positive, then the result is positive. In this case, the sign of the Modulus operation depends on the sign of the dividend. This is the module function which is an inbuilt function of the math module of function. The following examples would help to illustrate it: – We can have the divisor and the dividend as negative numbers, but the Modulus Operation will only return the remainder having the same sign as the divisor. NOTE: It is a best practice to always use try catch while doing Modulus Operation to do away with this Runtime Exception.
