Skip to main content

Posts

Showing posts with the label Reminder OPerator

What are results of the Remainder Operator in Java?

-- The remainder operator % returns the remainder from the division of the left operand by the right operand;the left-hand operand is the dividend and the right-hand operand is the divisor. In Java, the remainder operator % can be used with integral operands as well as floating-point operands ( $15.17.3 Remainder Operator % ). For the integral type remainder operation whose operands are integers after binary numeric promotion, the remainder operator is defined by the following identity (if b is not 0): (a/b)*b + a%b = a If the divisor b evaluates to zero, then an ArithmeticException is thrown. If the dividend evaluates to zero, the result is zero. The sign of the result equals the sign of the dividend. The magnitude of the result |a%b| is always less than the magnitude of the divisor |b|.