Date: Thu, 30 Sep 2004 14:40:01 -0500 From: Dan Nelson <dnelson@allantgroup.com> To: Andrew <infofarmer@mail.ru> Cc: freebsd-questions@freebsd.org Subject: Re: 64-bit arithmetic in scripts? Message-ID: <20040930194001.GD22530@dan.emsphone.com> In-Reply-To: <000601c4a720$99264270$4611a8c0@SATPC> References: <000601c4a720$99264270$4611a8c0@SATPC>
next in thread | previous in thread | raw e-mail | index | archive | help
In the last episode (Sep 30), Andrew said: > I'm counting traffic with ipfw and shell scripts. Is there a way to > use more than 32-bit numbers in shell arithmetic? POSIX only requires "signed long" support in the shell, but FreeBSD's expr command has a -e flag that will let it do 64-bit math: $ echo $(( 65536*65536 )) 0 $ echo $(expr 65536 "*" 65536) 0 $ echo $(expr -e 65536 "*" 65536) 4294967296 bash, ksh93 (but not pdksh), and zsh's shell arithmetic are all 64-bit, also. -- Dan Nelson dnelson@allantgroup.com
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20040930194001.GD22530>