Python Forum

Full Version: number of digits in a decimal.Decimal number object
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
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.