public inbox for cygwin@cygwin.com
 help / color / mirror / Atom feed
* Fwd: Re: Rounding off real (floating point) values - bash to awk
       [not found] <56574877.5080100@cs.umass.edu>
@ 2015-11-26 18:03 ` Eliot Moss
  0 siblings, 0 replies; only message in thread
From: Eliot Moss @ 2015-11-26 18:03 UTC (permalink / raw)
  To: cygwin

On 11/26/2015 12:20 PM, Helmut Karlowski wrote:
> ---------------------------------------------------
>> On Thu, Nov 26, 2015 at 10:29 AM, Steven Penny wrote:
>>> echo 3.7 | awk '{printf "%.0f", $0}'
>>
>> Another option
>>
>> awk 'BEGIN {printf "%.0f", ARGV[1]}' 3.7
>
> #4:
>
> printf "%3.0f\n" 3.7

Yes, while bash does not itself "do" floating point arithmetic,
it does have a printf builtin.  Also, you can do computations
using dc, and arbitrary precision calculator program, and you
can control the number of digits of precision used for output,
etc.

Regards -- Eliot Moss


--
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

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2015-11-26 18:00 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <56574877.5080100@cs.umass.edu>
2015-11-26 18:03 ` Fwd: Re: Rounding off real (floating point) values - bash to awk Eliot Moss

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).