X-Recipient: archive-cygwin AT delorie DOT com DomainKey-Signature: a=rsa-sha1; c=nofws; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:subject:reply-to:references:to:from:message-id :date:mime-version:in-reply-to:content-type :content-transfer-encoding; q=dns; s=default; b=bzSv4/wb4beZoQJG fiJYBDiAgTUiC67+X98gVtYDi9qJoAh6cpkA6x905J3l0VhlsT81PPLhclTSRyNY 11/F4cRgeq2fb+uBOA/YR3E/HRvBYSuMrNXb6AtPtUeqlBFKxxeBhFbZY+47lImd X1tD+YgXwz7Rz01ZwNM6I5BGykU= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:subject:reply-to:references:to:from:message-id :date:mime-version:in-reply-to:content-type :content-transfer-encoding; s=default; bh=SPi+vo2tbn+2YtQdipdshg hgLwg=; b=t9IxZEFUQqnwAnE9+9uPrYNBE4dF7YUvbGK1Y/cmTXYILbs3RjeARr cWkBUMOSukuDhuBD5N6aypcKp602lcK/46fYipsebfnTcWAaAJLOck7eDLmjpHXA MT3GfekE103DUY4vrASXXrofMbOTwGsOVXBIjMsLxiretyz8eHKZs= Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: cygwin-owner AT cygwin DOT com Mail-Followup-To: cygwin AT cygwin DOT com Delivered-To: mailing list cygwin AT cygwin DOT com Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.1 required=5.0 tests=AWL,BAYES_00,KAM_LAZY_DOMAIN_SECURITY,RP_MATCHES_RCVD autolearn=ham version=3.3.2 X-HELO: csmail.cs.umass.edu Subject: Fwd: Re: Rounding off real (floating point) values - bash to awk Reply-To: moss AT cs DOT umass DOT edu References: <56574877 DOT 5080100 AT cs DOT umass DOT edu> To: cygwin From: Eliot Moss X-Forwarded-Message-Id: <56574877 DOT 5080100 AT cs DOT umass DOT edu> Message-ID: <565748C2.5010402@cs.umass.edu> Date: Thu, 26 Nov 2015 13:00:34 -0500 User-Agent: Mozilla/5.0 (Windows NT 6.3; WOW64; rv:38.0) Gecko/20100101 Thunderbird/38.3.0 MIME-Version: 1.0 In-Reply-To: <56574877.5080100@cs.umass.edu> Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 7bit X-IsSubscribed: yes 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