Round remainder to prevent precision lost

Precision can be lost also with only substraction, so the remainder must be
rounded each time.

issue4067
review6521002