Homomorphic Encryption and the Approximate GCD Problem Confusion
The reference linked states in its Notation section (page vii):


  $a\bmod p\;\;$ Denotes reducing $a$ modulo $p$ into the interval $(-p/2, p/2]$


Thus the definition of $\bmod$ used is the non-standard
$$(a\bmod p)=r\;\iff\;p\text{ divides }a-r\;\text{ and }\;-p&lt;2r\le p$$

This can be viewed as the offset of $a$ from the nearest multiple of $p$ (with nearest selecting the lower as a tie-breaker), as suggested by a comment.

This can be programmed as r = ((a + (p-1)/2) % p) - (p-1)/2, making sure that


things are evaluated as signed integers (which in C can require some explicit casting for unsigned p);
the addition of (p-1)/2 does not cause overflow.