This is the mail archive of the
cygwin
mailing list for the Cygwin project.
Re: Rounding off real (floating point) values - bash to awk
- From: Steven Penny <svnpenn at gmail dot com>
- To: cygwin at cygwin dot com
- Date: Thu, 26 Nov 2015 10:29:23 -0600
- Subject: Re: Rounding off real (floating point) values - bash to awk
- Authentication-results: sourceware.org; auth=none
- References: <CAE3taFBHyMhcGB=ux5xYVxcLM13G2JRpuTyDG-NtuSrp=eOhmQ at mail dot gmail dot com>
On Thu, Nov 26, 2015 at 7:24 AM, Lester Anderson wrote:
> x=3.7
> awk -v x=$x 'BEGIN { printf "%3.0f\n", x }'
> which returns the value 4 as expected, but are there any other methods
> that can be used?
echo 3.7 | awk '{printf "%.0f", $0}'
--
Problem reports: http://cygwin.com/problems.html
FAQ: http://cygwin.com/faq/
Documentation: http://cygwin.com/docs.html
Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple