Sun Studio 12: C User's Guide

(6.3.5) The sign of the remainder on integer division:

The result is the same sign as the dividend; thus, the remainder of -23/4 is -3.