title: how to use float8 in postgres c user define function
body: <p>I am newer to postgres server programing and I want to achieve double+1;
  here is the code copy from <a href="https://www.postgresql.org/docs/9.6/static/xfunc-c.html" rel="nofollow noreferrer">https://www.postgresql.org/docs/9.6/static/xfunc-c.html</a>.</p>
  
  <pre><code>#include "postgres.h"
  #include &lt;string.h&gt;
  #include "utils/geo_decls.h"
  
  #ifdef PG_MODULE_MAGIC
  PG_MODULE_MAGIC;
  #endif
  
  float8 *
  add_one_float8(float8 *arg)
  {
      float8    *result = (float8 *) palloc(sizeof(float8));
  
      *result = *arg + 1.0;//if replace *arg with 1.5, it return normal(2.5)
  
      return result;
  }
  </code></pre>
  
  <p>I successfully create function.Everytimes I call function,the section was killed by postgres.</p>
  
  <p>Then I try to replace float8 *arg with float8 and then call function with statement</p>
  
  <pre><code>select add_one(1.5);
  </code></pre>
  
  <p>it return 1;
  it seems to arg is 0.And then I replace it with the following code</p>
  
  <pre><code>float8
  add_one_float8(float8 arg)
  {
      if(arg&gt;0){
          return arg+2;
      }else if(arg==0)
          return arg+3;
      else
          return arg+4;
  }
  </code></pre>
  
  <p>and then it return 2;
  I have no idea how to handle float8 or double in postgres,does anybody know how to fix it or what neccessary step I missed?Thanks advance.  </p>
  
  <p>By the way, both postgresql-9.5 and 9.6 I tries,the result is the same.Platform is linux,centos7</p>