4. For any $x, y \in \mathbf{R}, y \neq 0$, define the remainder
$$
\operatorname{rem}(x, y)=x-y\left[\frac{x}{y}\right],
$$

where $[a]$ denotes the greatest integer not exceeding the real number $a$. Then the value of $\operatorname{rem}\left(\frac{3}{8},-\frac{2}{5}\right)$ is $(\quad)$.
(A) $-\frac{3}{8}$
(B) $-\frac{1}{40}$
(C) 0
(D) $\frac{3}{8}$
(E) $\frac{31}{40}$
4. B.

From the problem, we know
$$
\begin{array}{l}
\operatorname{rem}\left(\frac{3}{8},-\frac{2}{5}\right)=\frac{3}{8}-\left(-\frac{2}{5}\right)\left[\frac{\frac{3}{8}}{-\frac{2}{5}}\right] \\
=\frac{3}{8}-\left(-\frac{2}{5}\right)\left[-\frac{3}{8} \times \frac{5}{2}\right] \\
=\frac{3}{8}-\left(-\frac{2}{5}\right)(-1)=-\frac{1}{40} .
\end{array}
$$