function mod_pm, x, m

;+
; MOD_PM
;	Return a 2-sided modulo.
;
; Usage:
;	mv = mod_pm(x,m)
;
; Return Value:
;	mv	as x	The modulo'ed value
;
; Arguments:
;	x	num	The value to modulo
;	m	num	The modulus.
;
; History:
;	Original: 23/11/09; SJT
;-

m2 = m*2

x1 = x mod m2
locs = where(x1 lt 0, nn)
if nn ne 0 then x1[locs] += m2
locs = where(x1 gt m, nb)
if nb ne 0 then x1[locs] -= m2

return, x1

end
