In Ruby:
-2 % 24
=> 22
In Postgres:
SELECT -2 % 24;
?column?
----------
-2
SELECT mod(-2,24);
mod
-----
-2
I can easily write one myself, but I'm curious whether Postgres has a real modulus operation, as opposed to remainder after division.
SELECT MOD(24 + MOD(-2, 24), 24);
will return 22 instead of -2
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With