Properly handle systems where (-ve % +ve) returns +ve

Can't just use abs()

This is the correct fix rather than c7e5c48

Signed-off-by: Steve Bennett <steveb@workware.net.au>