aboutsummaryrefslogtreecommitdiff
path: root/thcolor/utils.py
diff options
context:
space:
mode:
Diffstat (limited to 'thcolor/utils.py')
-rw-r--r--thcolor/utils.py11
1 files changed, 9 insertions, 2 deletions
diff --git a/thcolor/utils.py b/thcolor/utils.py
index ad71367..7d60d0c 100644
--- a/thcolor/utils.py
+++ b/thcolor/utils.py
@@ -41,9 +41,16 @@ def round_half_up(number: float, ndigits: _Optional[int] = None) -> float:
base = 10 ** -ndigits
- return (number // base) * base + (
- base if (number % base) >= (base / 2) else 0
+ result = round(
+ (number // base) * base + (
+ base if (number % base) >= (base / 2) else 0
+ ),
+ ndigits=ndigits,
)
+ if result == int(result):
+ result = int(result)
+ return result
+
# End of file.