Time-resolved Kerr rotation spectroscopy is used to determine the sign of the g factor of carriers in a semiconductor material, with the help of a rotatable magnetic field in the plane of the sample. The spin precession signal of carriers at a fixed time delay is measured as a function of the orientation of the magnetic field with a fixed strength B. The signal has a sine-like form and its phase determines the sign of the g factor of carriers. As a natural extension of previous methods to measure the (time-resolved) photoluminescence or time-resolved Kerr rotation signal as a function of the magnetic field strength with a fixed orientation, such a method gives the correct sign of the g factor of electrons in GaAs. Furthermore, the sign of carriers in a (Ga, Mn)As magnetic semiconductor is also found to be negative.