From db9b04be59f289614a764129111edbc2a30cfd7e Mon Sep 17 00:00:00 2001 From: GenevensiS <66968533+G-e-n-e-v-e-n-s-i-S@users.noreply.github.com> Date: Sun, 9 Feb 2025 01:19:42 +0100 Subject: [PATCH] Fix bug when rounding negative numbers (#122) * Fix bug when rounding negative numbers --- data/magic.mse-game/script | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/data/magic.mse-game/script b/data/magic.mse-game/script index 041942e7c..ea2b33e3a 100644 --- a/data/magic.mse-game/script +++ b/data/magic.mse-game/script @@ -97,9 +97,14 @@ clamp := { else if number > maximum then maximum else number } -round_up := {to_int(0.99999999999998+input)} #### 0.99999999999999 == 1, leave the 8 -round_near := {to_int(0.5+input)} to_number_lax := { to_number(input) or else to_number(trim(input)) or else 0 } +round_near := { if input < 0 then to_int(input-0.5) else to_int(input+0.5) } +#### 0.99999999999999 == 1, leave the 8 +round_up := { + if input < 0 + then to_int(input-0.99999999999998) + else to_int(input+0.99999999999998) +} #### type_name("string") returns string ("string") so fix that #### type_name(nil) is fine