I have a variable in Python containing a floating point number (e.g. num = 24654.123), and I\'d like to determine the number\'s precision and scale values (in t
I found another solution that seems to be simpler, but I'm not sure exactly if it will work for all cases.
import math
x = 1.2345678
def flip(string):
result = ""
for ch in string:
result = ch + result
return result
prec = int(math.log10(float(flip(str(x)))) + 1 # precision as int