Twos complement function in moodle.c