News for hackers. Stuff that matters.
Re:Aztec monks with 1/55 HP no longer die when picking up or... by layer8 on Saturday April 15, 2023 @04:03AM (#35578622)
> So it should have been `(new_maxhp * old_hp) / old_maxhp`.

I don't see how that couldn't run into similar problems. I would use `clamp(old_hp * (new_maxhp / old_maxhp), 1, new_maxhp)` (assuming that old_hp >= 1).

Re:Aztec monks with 1/55 HP no longer die when picking up or... by tpolzer on Saturday April 15, 2023 @04:16AM (#35578692)
If you assume that all three numbers are small integers, doing the division last minimizes precision loss (and doesn't have any loss if the accurate result is representable as a float).

Otherwise you get loss from the division and then multiply that loss (by >1).

Re:Aztec monks with 1/55 HP no longer die when picking up or... by iforgotpassword on Saturday April 15, 2023 @04:14AM (#35578684)
It could, but only at very large values. It's at least the much more robust solution.