title: How to read an ArrayBuffer with binary data in "4 byte single"/floating point/IEEE 754 encoded data?
body: <p>I need to loop over a binary file via an <code>arrayBuffer</code>and retrieve sets of 1024 floating points. I'm doing this:</p>
  
  <pre><code>// chunk_size = 1024
  // chunk_len = 48
  // response_buffer = ArrayBuffer
  // response_buffer.byteLength = 49152
  for (i = chunk_len; i &gt; 0; i -= 1) {
      switch (i) {
          case (chunk_len):
  
              // create view from last chunk of 1024 out of 49152 total
              float_buffer = new Float32Array(response_buffer, ((i - 1) * chunk_size));
  
              // add_data(net_len, float_buffer);
              break;
  
          case 0:
              break;
  
          default:
              float_buffer = new Float32Array(response_buffer, ((i - 1) * chunk_size)), chunk_size);
              //add_data(net_len, float_buffer);
              break;
      }
  }
  </code></pre>
  
  <p>My problem is if I call this on the first run for the end of my buffer:</p>
  
  <pre><code>// i - 1 = 47 * chunk_size
  new Float32Array(response_buffer, ((i - 1) * chunk_size));
  </code></pre>
  
  <p>the same statement fails on the next run where I call:</p>
  
  <pre><code>new Float32Array(response_buffer, ((i - 1) * chunk_size), 1024);
  </code></pre>
  
  <p>Although I can read <a href="https://developer.mozilla.org/en-US/docs/Web/API/Float32Array" rel="nofollow">here</a>, that 
  I can do this:</p>
  
  <pre><code>Float32Array Float32Array(
      ArrayBuffer buffer,
      optional unsigned long byteOffset,
      optional unsigned long length
  );
  </code></pre>
  
  <p><strong>Question</strong>:<br>
  Why is my loop failing after declaring the first <code>Float32Array</code> view on my <code>response_offer</code> ArrayBuffer?</p>