Fix issue 11576.

This bug is caused by careless code when dealing with unsigned quantities.

https://d.puremagic.com/issues/show_bug.cgi?id=11576