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