i am basically coming from java background and struggling to understand the modulo operation in Ruby.
(5 % 3) (-5 % 3) (5 % -3) (-5 % -3)
Because Ruby defines x.modulo(y) to be x-y*(x/y).floor. See ruby-doc.org
x.modulo(y)
x-y*(x/y).floor