Correct handling of singed integers

Thank you Daniel Heule