Python Forum
number of digits in a decimal.Decimal number object - Printable Version

+- Python Forum (https://python-forum.io)
+-- Forum: General (https://python-forum.io/forum-1.html)
+--- Forum: News and Discussions (https://python-forum.io/forum-31.html)
+--- Thread: number of digits in a decimal.Decimal number object (/thread-40615.html)



number of digits in a decimal.Decimal number object - Skaperen - Aug-26-2023

given a decimal number (via args in a function, for example), i can find out how many digits it has with:
how_many_digits = len(str(a_decimal_number))-1
is there a better. more appropriate, way to do that, that i may have missed? i want to get the minimum precision i need to set to work with this decimal number in decimal. i may decide to use twice as many to cover extreme cases with multiplication and division.