title: Determine precision and scale of particular number in Python
body: <p>I have a variable in Python containing a floating point number (e.g. <code>num = 24654.123</code>), and I'd like to determine the number's precision and scale values (in the Oracle sense), so 123.45678 should give me (8,5), 12.76 should give me (4,2), etc.</p>
  
  <p>I was first thinking about using the string representation (via <code>str</code> or <code>repr</code>), but those fail for large numbers (although I understand now it's the limitations of floating point representation that's the issue here):</p>
  
  <pre><code>&gt;&gt;&gt; num = 1234567890.0987654321
  &gt;&gt;&gt; str(num) = 1234567890.1
  &gt;&gt;&gt; repr(num) = 1234567890.0987654
  </code></pre>
  
  <p><b>Edit:</b></p>
  
  <p>Good points below. I should clarify. The number is already a float and is being pushed to a database via cx_Oracle. I'm trying to do the best I can in Python to handle floats that are too large for the corresponding database type short of executing the INSERT and handling Oracle errors (because I want to deal with the numbers a field, not a record, at a time). I guess <code>map(len, repr(num).split('.'))</code> is the closest I'll get to the precision and scale of the float?</p>