It is definitely not mathematically accurate behavior. Modulo should never return a negative number.
It is implemented differently across different languages. Some use the mathematical definition, some do not.