From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 23829 invoked by alias); 12 Sep 2014 16:17:44 -0000 Mailing-List: contact zsh-users-help@zsh.org; run by ezmlm Precedence: bulk X-No-Archive: yes List-Id: Zsh Users List List-Post: List-Help: X-Seq: 19070 Received: (qmail 20927 invoked from network); 12 Sep 2014 16:17:29 -0000 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00 autolearn=ham version=3.3.2 Date: Fri, 12 Sep 2014 18:17:24 +0200 From: Roman Neuhauser To: Zsh Users Subject: Re: Determining the length of "long"? Message-ID: <20140912161724.GY4075@isis.sigpipe.cz> References: <20140911213608.GA1029@gmx.de> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20140911213608.GA1029@gmx.de> User-Agent: Mutt/1.5.23 (2014-03-12) # dominik.vogt@gmx.de / 2014-09-11 22:36:08 +0100: > Is there a way to determine the length of the C type long from > inside a zsh script (without using external programs, of course). > > As an alternative, is there a direct way to print out a "long" > integer value as binary bytes in host byte order? > > I.e. given a value, say 0x12345, I need to print that as > > \\x00\\x01\\x23\\x45 > > on a 32 bit platform, and as > > \\x00\\x00\\x00\\x00\\x00\\x01\\x23\\x45 > > on a 64 bit platform (possibly in reverse byte order, depending on > the hardware). see getconf(1)[0] and unistd.h(0P)[1], specifically _POSIX_V6_ILP32_OFF32 and its brethren. [0]: http://pubs.opengroup.org/onlinepubs/9699919799/utilities/getconf.html [1]: http://pubs.opengroup.org/onlinepubs/9699919799/basedefs/unistd.h.html -- roman