title: Why is a**2 != a * a for some floats?
body: <pre><code>$ python --version
  Python 2.7.15
  
  $ type test.py
  import random
  
  while True:
      a = random.uniform(0, 1)
      b = a ** 2
      c = a * a
      if b != c:
          print "a = {}".format(a)
          print "a ** 2 = {}".format(b)
          print "a * a = {}".format(c)
          break
  
  $ python test.py
  a = 0.145376687586
  a ** 2 = 0.0211343812936
  a * a = 0.0211343812936
  </code></pre>
  
  <p>I was only able to reproduce this on a Windows build of Python - to be precise: <code>Python 2.7.15 (v2.7.15:ca079a3ea3, Apr 30 2018, 16:30:26) [MSC v.1500 64 bit (AMD64)] on win32</code>. On my <a href="http://en.wikipedia.org/wiki/Arch_Linux" rel="nofollow noreferrer">Arch Linux</a> box installation of Python (<code>Python 2.7.15 (default, May 1 2018, 20:16:04) [GCC 7.3.1 20180406] on linux2</code>) the loop does not seem to terminate indicating that the <code>a**2 = a * a</code> invariant holds there.</p>
  
  <p>What is going on here? I know that IEEE floats come with a plethora of misconceptions and idiosyncrasies (<a href="https://stackoverflow.com/questions/588004/is-floating-point-math-broken">this</a>, for example, does not answer my question), but I fail to see what part of the specification or what kind of implementation of <code>**</code> could possibly allow for this.</p>
  
  <p>To address the duplicate flagging: This is most likely not directly an IEEE floating point math problem and more of a implementation issue of the <code>**</code> operator. Therefore, this is not a duplicate of questions which are only asking about floating point issues such as precision or associativity.</p>