mirror of
https://github.com/LBRYFoundation/LBRY-Vault.git
synced 2025-08-31 17:31:36 +00:00
fix #4759
This commit is contained in:
parent
b37695f9c8
commit
70cca3bad9
1 changed files with 9 additions and 3 deletions
|
@ -511,15 +511,21 @@ def format_satoshis(x, num_zeros=0, decimal_point=8, precision=None, is_diff=Fal
|
|||
return 'unknown'
|
||||
if precision is None:
|
||||
precision = decimal_point
|
||||
# format string
|
||||
decimal_format = ".0" + str(precision) if precision > 0 else ""
|
||||
if is_diff:
|
||||
decimal_format = '+' + decimal_format
|
||||
result = ("{:" + decimal_format + "f}").format(x / pow (10, decimal_point)).rstrip('0')
|
||||
# initial result
|
||||
scale_factor = pow(10, decimal_point)
|
||||
result = ("{:" + decimal_format + "f}").format(Decimal(x) / scale_factor)
|
||||
if "." not in result: result += "."
|
||||
result = result.rstrip('0')
|
||||
# extra decimal places
|
||||
integer_part, fract_part = result.split(".")
|
||||
dp = DECIMAL_POINT
|
||||
if len(fract_part) < num_zeros:
|
||||
fract_part += "0" * (num_zeros - len(fract_part))
|
||||
result = integer_part + dp + fract_part
|
||||
result = integer_part + DECIMAL_POINT + fract_part
|
||||
# leading/trailing whitespaces
|
||||
if whitespaces:
|
||||
result += " " * (decimal_point - len(fract_part))
|
||||
result = " " * (15 - len(result)) + result
|
||||
|
|
Loading…
Add table
Reference in a new issue