Fix bug when rounding negative numbers (#122)

* Fix bug when rounding negative numbers
This commit is contained in:
GenevensiS
2025-02-09 01:19:42 +01:00
committed by GitHub
parent 468dc01717
commit db9b04be59

View File

@@ -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