i am basically coming from java background and struggling to understand the modulo operation in Ruby.
(5 % 3) (-5 % 3) (5 % -3) (-5 % -3)
In Java, the result of the modulo operation has the same sign as the dividend.
In Ruby, it has the same sign as the divisor. remainder() in Ruby has the same sign as the dividend.
remainder()
You might also want to refer to modulo operation.