The discriminant check was not working correctly for negative numbers. This change fixes that by masking out the relevant bits correctly.