delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2015/11/26/11:29:43

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:mime-version:in-reply-to:references:date
:message-id:subject:from:to:content-type; q=dns; s=default; b=pj
fd8dWANM0JriceAajvfD9x2WFXZNN/Ekq/Lf0KB2SVyPJRGCpweG52Efd1U2ICUS
g6Y/fDeGVeOqyLH8tg939NXt4iOfHBZKgvT0eR3Z4MQx0fGGjyavAkSY2t+nSeyA
su+zaw2CpOrV54Cjf1Q1lv7D02NOyzyYDx4FmZw9Y=
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:mime-version:in-reply-to:references:date
:message-id:subject:from:to:content-type; s=default; bh=5bEb8gM4
aKKSI5j8usjWBbvuKX0=; b=v/e4PYdS8PtBl15K9KBQODhBmcsLZXDY01tt76Ci
EloFw7aj6xtMEhZkABbEdmFt2i3ar/id6CrgdxB84wSiyybKIkWMQYh+ivZjdTSK
VqzdLL4RpuVNk33JnveISpU9QvKz6PYrHPUtvvNUHOgzUwjjbYYx/FzzNGMaVdmr
/oY=
Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm
List-Id: <cygwin.cygwin.com>
List-Subscribe: <mailto:cygwin-subscribe AT cygwin DOT com>
List-Archive: <http://sourceware.org/ml/cygwin/>
List-Post: <mailto:cygwin AT cygwin DOT com>
List-Help: <mailto:cygwin-help AT cygwin DOT com>, <http://sourceware.org/ml/#faqs>
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=-2.3 required=5.0 tests=AWL,BAYES_00,FREEMAIL_FROM,RCVD_IN_DNSWL_LOW,SPF_PASS autolearn=ham version=3.3.2
X-HELO: mail-io0-f174.google.com
MIME-Version: 1.0
X-Received: by 10.107.15.13 with SMTP id x13mr38993269ioi.64.1448555363998; Thu, 26 Nov 2015 08:29:23 -0800 (PST)
In-Reply-To: <CAE3taFBHyMhcGB=ux5xYVxcLM13G2JRpuTyDG-NtuSrp=eOhmQ@mail.gmail.com>
References: <CAE3taFBHyMhcGB=ux5xYVxcLM13G2JRpuTyDG-NtuSrp=eOhmQ AT mail DOT gmail DOT com>
Date: Thu, 26 Nov 2015 10:29:23 -0600
Message-ID: <CAAXzdLWK6hexdYcQM6CcvxVmE=ctyTqnYYHN_r+B6qC-8thVFw@mail.gmail.com>
Subject: Re: Rounding off real (floating point) values - bash to awk
From: Steven Penny <svnpenn AT gmail DOT com>
To: cygwin AT cygwin DOT com
X-IsSubscribed: yes

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

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019