title: How to round, floor, ceil, truncate
body: <p>How can I round, floor, ceil, and truncate a number in jq jq-1.5-1-a5b5cbe?</p>
  
  <p>For example, with <code>{"mass": 188.72}</code>, I want <code>{"mass": 188}</code> with floor, <code>{"mass": 189}</code> with ceil and round.</p>
  
  <p>Rounding examples:</p>
  
  <pre><code>5.52 --&gt; 6
  5.50 --&gt; 5 or 6
  -5.52 --&gt; -6
  </code></pre>
  
  <p>Truncate examples:</p>
  
  <pre><code>5.52 --&gt; 5
  5.50 --&gt; 5
  -5.52 --&gt; -5
  </code></pre>
  
  <p>I have come up with <code>-5 as $n | if $n &gt; 0 then [range($n+0.00000000000001)] else [range(-$n)] end | last</code> for truncate, but it is needlessly complex (and likely contains bugs).</p>