title: PostgreSQL - rounding floating point numbers
body: <p>I have a newbie question about floating point numbers in PostgreSQL 9.2.</p>
  
  <p>Is there a function to round a floating point number directly, i.e. without having to convert the number to a numeric type first? </p>
  
  <p>Also, I would like to know whether there is a function to round by an arbitrary unit of measure, such as to nearest 0.05?</p>
  
  <p>When casting the number into a decimal form first, the following query works perfectly:</p>
  
  <pre><code>SELECT round(1/3.::numeric,4);
  
   round  
  --------
   0.3333
  (1 row)
  Time: 0.917 ms
  </code></pre>
  
  <p>However, what really I'd like to achieve is something like the following:</p>
  
  <pre><code>SELECT round(1/3.::float,4);
  </code></pre>
  
  <p>which currently gives me the following error:</p>
  
  <pre><code>ERROR:  function round(double precision, integer) does not exist at character 8
  Time: 0.949 ms
  </code></pre>
  
  <p>Thanks</p>