Fix bug when rounding negative numbers (#122)
* Fix bug when rounding negative numbers
This commit is contained in:
@@ -97,9 +97,14 @@ clamp := {
|
|||||||
else if number > maximum then maximum
|
else if number > maximum then maximum
|
||||||
else number
|
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 }
|
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("string") returns string ("string") so fix that
|
||||||
#### type_name(nil) is fine
|
#### type_name(nil) is fine
|
||||||
|
|||||||
Reference in New Issue
Block a user