diff options
author | Thomas Touhey <thomas@touhey.fr> | 2022-01-02 16:36:16 +0100 |
---|---|---|
committer | Thomas Touhey <thomas@touhey.fr> | 2022-02-02 22:12:58 +0100 |
commit | 3708f0dd0bc98d9688fcf0dada282c12d0cecd95 (patch) | |
tree | ca135a1b76b72d2ae1315513806d352c11aca8eb /thcolor/utils.py | |
parent | 4a947057b709c6536f6a940645254bf0feadcd8c (diff) |
Adding in more tests and fixing a few style issues
Diffstat (limited to 'thcolor/utils.py')
-rw-r--r-- | thcolor/utils.py | 11 |
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. |