title: How to typecast a float tensor into long tensor without rounding error?
body: <p>I have a float tensor made by multiplying a matrix by its inverse (so the identity matrix). When I convert to int, it is not the identity matrix, i.e, 1.0000e00 becomes 0.  I need a way to typecast with rounding.</p>
  
  <p>I have tried typecasting using .int() and .long() but they round to zero. Specifically:</p>
  
  <pre><code>I = tensor([[ 1.0000e+00,  1.1921e-07, -1.1921e-07],
          [-5.9605e-08,  1.0000e+00,  0.0000e+00],
          [-2.9802e-08,  0.0000e+00,  1.0000e+00]])
  I = I.long()
  print(I)
  </code></pre>
  
  <p>gives:</p>
  
  <pre><code>tensor([[0, 0, 0],
          [0, 1, 0],
          [0, 0, 0]])
  </code></pre>
  
  <p>What should happen is that <code>print(I)</code> returns </p>
  
  <pre><code>tensor([[1, 0, 0],
          [0, 1, 0],
          [0, 0, 1]])
  </code></pre>
  
  <p>What line of code will change my tensor into what I want? It should only take one line.</p>