>Not sure where that one got added or lost between the two calculations.
Your math is wrong. Instead of
(200 * 21474837) % 0xFFFFFFFF
It should be (200 * 21474837) % 0x100000000
Then you get 104. The integer wrap point is 0x100000000 (because 0x100000000 is congruent to 0 in a 32 bit int). Similarly, the math to calculate the quantity should be math.floor((0x100000000/200) + 1) if a 0 total cost isn't allowed, or math.ceil(0x100000000/200) if a 0 total cost is allowed.