title: process of mapping a floating point literal to its binary representation
body: <p>Consider the exact float values around 0.3</p>
  
  <pre><code>1) 0.2999999523162841796875
  2) 0.2999999821186065673828125
  3) 0.300000011920928955078125
  4) 0.3000000417232513427734375
  5) 0.30000007152557373046875
  </code></pre>
  
  <p>When we write the following code in C++</p>
  
  <pre class="lang-cpp prettyprint-override"><code>auto x = 0.30f
  </code></pre>
  
  <p>compiler has to parse the <code>0.30f</code> token and make x of type float with value <code>0.300000011920928955078125</code>. (option 3 above)</p>
  
  <p>I am curious how compilers reach that value, and not the values around it. One theory is that they call <code>strtof</code> function to get the float. <a href="https://github.com/ochafik/LibCL/blob/master/src/main/resources/LibCL/strtof.c" rel="nofollow noreferrer">Here</a> is implementation of strtof (it is basically going through each character of the string, multiplying by a power of 10 and figuring out the location of decimal). It is not obvious to me why this method will give option 3 and not option 4 or 5. </p>