I want to print 0.74 for 0.748.
If I use
awk '{printf "%0.2f\n",$1}' filename
for 0.748 it prints 0.75. But I want 0.74 and remove remaining part. For 77.348 it should be 77.34.
Any ideas?
There is no
gawk -M
option to use ROUNDMODE="Z" ??
Even I couldn't find ceiling and floor functions as well.
"%.4s\n"
? – steeldriver Jul 13 '15 at 11:14%d
conversion specifier. On 15.04 with GNU awk 4.1.1, it is possible to use MPFR to set theROUNDMODE
explicitly - see Setting the Rounding Mode but AFAIK that's not available in other versions/varieties – steeldriver Jul 13 '15 at 11:31