When accessing single element from list of float values, value get's rounded off
<p>My list contains values which are converted to float :</p>

<pre><code>time = [1472120400.107, 1472120399.999, 1472120399.334, 1472120397.633,
1472120397.261, 1472120394.328, 1472120393.762, 1472120393.737]
</code></pre>

<p>But when i do <code>time[0]</code>, the value gets rounded off to 2 decimal places like <code>1472120400.11</code> . How do I retain the original values (upto 3 decimal places for accurate calculations) when accessing single list values?</p>

<p>My code:</p>

<pre><code>for line in line_collect :
    a = re.search(rx1,line) 
    time = a.group()
    newlst.append(float(time))
    print newlst
    print newlst[0]
</code></pre>

<p>Output:</p>

<blockquote>
  <p>[1472120400.107, 1472120399.999, 1472120399.334, 1472120397.633,
  1472120397.261, 1472120394.328, 1472120393.762, 1472120393.737]</p>
  
  <p>1472120400.11</p>
</blockquote>

<p>The list itself doesn't have rounded values.  It is the default "print" that shows rounding:</p>

<pre><code>&gt;&gt;&gt; time = [1472120400.107, 1472120399.999, 1472120399.334, 1472120397.633,
1472120397.261, 1472120394.328, 1472120393.762, 1472120393.737]
&gt;&gt;&gt; time[0]
1472120400.107
&gt;&gt;&gt; print time[0]
1472120400.11
</code></pre>

<p>You can get full precision output by printing the <a href="https://docs.python.org/2.7/library/functions.html#func-repr" rel="nofollow"><em>repr</em></a> instead:</p>

<pre><code>&gt;&gt;&gt; print repr(time[0])
1472120400.107
</code></pre>

python python-2.7