title: How to sum a list of float numbers in OCaml
body: <p>I am puzzled with my code:</p>
  
  <pre><code>let sum l = match l with
    | [] -&gt; 0.0
    | h::t -&gt; h +. (sum t);;
  </code></pre>
  
  <p>It should give me the sum of the numbers in the list. However when I check the code, I found the second code crashes when I use a list of length greater than or equal to 7. Here is the code:</p>
  
  <pre><code># sum [0.;1.;2.;3.;4.;5.;]
  
  - : float = 15.
  
  # sum [0.;1.;2.;3.;4.;5.;6.]
  
  - : float = 21.
  # sum [0.;1.;2.;3.;4.;5.;6.;7.]
  
  - : float = 21.
  </code></pre>
  
  <p>I am really confused because a modification of it, which operates on int, turned out to be normal:</p>
  
  <pre><code>let rec sumf l = match l with
    | []-&gt; 0.0
    | h::t-&gt; (float_of_int h) +. sumf t;;
  </code></pre>
  
  <p>and I do not know what is the essential difference between the two aside from I cast int into float in the second code. </p>