nlg_num #
The nlg_num method allows to transform a number in a string following several criterion.
Parameter | Type | Default Value |
---|---|---|
The number | int or float or Decimal | |
sep (the separator for the decimal) | string | ‘.’ |
mile_sep (the seperator for mile) | string | ' ' |
dec (the number of decimals to display) | int | None (all decimals) |
force_sign (whether to add ‘+’ before the number if is positive) | boolean | False |
remove_trailing_zeros (whether to remove not significant 0 in the decimals) | boolean | True |
nlg = NlgTools()
my_number = 10000.66028
str_num = nlg.nlg_num(my_number, dec=3, force_sign=True)
print(str_num)
# +10 000.66
# The remove_trailing_zeros parameter will remove the last decimal even though we indicated 3 decimals because it is a 0.