Handle signed vs. unsigned integer values correctly