From owner-freebsd-questions@FreeBSD.ORG Wed Mar 3 01:02:23 2004 Return-Path: Delivered-To: freebsd-questions@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 6E68416A4CE for ; Wed, 3 Mar 2004 01:02:23 -0800 (PST) Received: from lillith-iv.ovirt.dyndns.ws (ppp36-152.lns1.adl1.internode.on.net [150.101.36.152]) by mx1.FreeBSD.org (Postfix) with ESMTP id 6A98143D1D for ; Wed, 3 Mar 2004 01:02:22 -0800 (PST) (envelope-from ws+freebsd-questions@au.dyndns.ws) X-Envelope-From: ws+freebsd-questions@au.dyndns.ws X-Envelope-To: freebsd-questions@freebsd.org Received: from [192.168.100.132] (ppp36-152.lns1.adl1.internode.on.net [150.101.36.152])i2392Ba8052349; Wed, 3 Mar 2004 19:32:12 +1030 (CST) (envelope-from ws+freebsd-questions@au.dyndns.ws) From: Wayne Sierke To: Dan Nelson In-Reply-To: <20040303080359.GB79860@dan.emsphone.com> References: <1078286126.666.11.camel@ovirt.dyndns.ws> <20040303080359.GB79860@dan.emsphone.com> Content-Type: text/plain Message-Id: <1078304560.666.157.camel@ovirt.dyndns.ws> Mime-Version: 1.0 X-Mailer: Ximian Evolution 1.4.5 Date: Wed, 03 Mar 2004 19:32:40 +1030 Content-Transfer-Encoding: 7bit X-Spam-Score: 0 () X-Scanned-By: MIMEDefang 2.38 cc: freebsd-questions@freebsd.org Subject: Re: Size of variables in awk X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 03 Mar 2004 09:02:23 -0000 On Wed, 2004-03-03 at 18:34, Dan Nelson wrote: > In the last episode (Mar 03), Wayne Sierke said: > > It seems I've run into the 32-bit signed number wall in awk > > (5.2-RELEASE). > > > > My totals are maxing out at 2147483648. > > > > Would anyone happen to know whether that's really the case (that awk is > > only implemented with 32-bit number capability - unfortunately I don't > > have any other awks nearby to verify nor can I find any reference info > > that indicates) and/or can suggest a way around it? > > Seems to works fine on -current: > > $ jot 8 30 | awk '{ print 2^$1 }' > 1073741824 > 2147483648 > 4294967296 > 8589934592 > 17179869184 > 34359738368 > 68719476736 > 137438953472 Ah, ok. Same for me on 5.2-RELEASE. More info: I'm using the printf function in awk but something ain't right: # jot 4 30 | awk '{ printf("%u\n", 2^$1-1) }' 1073741823 2147483647 2147483648 2147483648 # jot 4 30 | awk '{ printf("%lu\n", 2^$1-1) }' 1073741823 2147483647 2147483648 2147483648 # jot 4 30 | awk '{ printf("%llu\n", 2^$1-1) }' 35185445830655 35186519572479 35186519572480 35186519572480 Thoughts? Wayne