Skip to content

Commit

Permalink
Accept SomeNumber as the number
Browse files Browse the repository at this point in the history
  • Loading branch information
Danil Yarantsev (Yardanico) committed Mar 30, 2022
1 parent c43e122 commit 82799bc
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/millie.nim
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ const units = [


proc millify*(
value: int64,
value: SomeNumber,
precision: int = 1,
lowercase: bool = false,
space: bool = false,
Expand All @@ -37,6 +37,10 @@ proc millify*(
val = res
unitIndex += 1

# The number is too big for Millie to handle. So,
# Millie just returns it as is.
if len(units) <= unitIndex: return $value

# round the decimal number up to the desired precision
let rounded = val.round(precision)
let ceil = rounded.ceil()
Expand Down

0 comments on commit 82799bc

Please sign in to comment.